Struct WebSocketMessage
pub struct WebSocketMessage {
pub type: WebSocketMessageType,
pub time: f64,
pub opcode: WebSocketMessageOpcode,
pub data: ArcStr,
}http and std only.Expand description
A Chrome DevTools WebSocket message stored in an HAR entry’s
_webSocketMessages extension.
Chrome exports complete text and binary messages rather than fragmented wire frames, plus protocol errors. Control frames and connection-close events are not included. The shape is unchanged from the Chrome 76 announcement and the current Chromium DevTools HAR exporter.
Fields§
§type: WebSocketMessageTypeWhether the message was sent, received, or reports a protocol error.
time: f64Unix timestamp in seconds, including any fractional part.
Unlike HAR’s startedDateTime, Chromium emits this as a JSON number.
opcode: WebSocketMessageOpcodeWebSocket opcode, or WebSocketMessageOpcode::ERROR for an error record.
data: ArcStrMessage payload.
Text messages and error records contain their original text. Chromium’s DevTools Protocol supplies non-text message data as base64, so binary messages use a base64 string here.
Implementations§
§impl WebSocketMessage
impl WebSocketMessage
pub fn new(
type: WebSocketMessageType,
time: f64,
opcode: WebSocketMessageOpcode,
data: impl Into<ArcStr>,
) -> WebSocketMessage
pub fn new( type: WebSocketMessageType, time: f64, opcode: WebSocketMessageOpcode, data: impl Into<ArcStr>, ) -> WebSocketMessage
Create a message with an explicitly supplied opcode and already encoded data.
pub fn text(
type: WebSocketMessageType,
time: f64,
data: impl Into<ArcStr>,
) -> WebSocketMessage
pub fn text( type: WebSocketMessageType, time: f64, data: impl Into<ArcStr>, ) -> WebSocketMessage
Create a text message (opcode: 1).
pub fn binary(
type: WebSocketMessageType,
time: f64,
data: impl AsRef<[u8]>,
) -> WebSocketMessage
pub fn binary( type: WebSocketMessageType, time: f64, data: impl AsRef<[u8]>, ) -> WebSocketMessage
Create a binary message (opcode: 2), base64-encoding the supplied bytes.
pub fn binary_with_opcode(
type: WebSocketMessageType,
time: f64,
opcode: WebSocketMessageOpcode,
data: impl AsRef<[u8]>,
) -> WebSocketMessage
pub fn binary_with_opcode( type: WebSocketMessageType, time: f64, opcode: WebSocketMessageOpcode, data: impl AsRef<[u8]>, ) -> WebSocketMessage
Create a non-text message and base64-encode its payload.
pub fn error(time: f64, message: impl Into<ArcStr>) -> WebSocketMessage
pub fn error(time: f64, message: impl Into<ArcStr>) -> WebSocketMessage
Create the error record shape used by Chromium (type: "error", opcode: -1).
pub fn binary_data(&self) -> Option<Result<Vec<u8>, DecodeError>>
pub fn binary_data(&self) -> Option<Result<Vec<u8>, DecodeError>>
Decode a binary message’s base64 payload.
Returns None for other opcodes. A malformed base64 payload remains visible
as a decode error instead of being silently discarded.
Trait Implementations§
§impl Clone for WebSocketMessage
impl Clone for WebSocketMessage
§fn clone(&self) -> WebSocketMessage
fn clone(&self) -> WebSocketMessage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for WebSocketMessage
impl Debug for WebSocketMessage
§impl<'de> Deserialize<'de> for WebSocketMessage
impl<'de> Deserialize<'de> for WebSocketMessage
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<WebSocketMessage, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<WebSocketMessage, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl PartialEq for WebSocketMessage
impl PartialEq for WebSocketMessage
§impl Serialize for WebSocketMessage
impl Serialize for WebSocketMessage
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for WebSocketMessage
Auto Trait Implementations§
impl Freeze for WebSocketMessage
impl RefUnwindSafe for WebSocketMessage
impl Send for WebSocketMessage
impl Sync for WebSocketMessage
impl Unpin for WebSocketMessage
impl UnsafeUnpin for WebSocketMessage
impl UnwindSafe for WebSocketMessage
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more