Struct Frame
pub struct Frame { /* private fields */ }Available on crate feature
ws only.Expand description
A struct representing a WebSocket frame.
Implementations§
§impl Frame
impl Frame
pub fn len(&self) -> usize
pub fn len(&self) -> usize
Get the length of the frame. This is the length of the header + the length of the payload.
pub fn header(&self) -> &FrameHeader
pub fn header(&self) -> &FrameHeader
Get a reference to the frame’s header.
pub fn header_mut(&mut self) -> &mut FrameHeader
pub fn header_mut(&mut self) -> &mut FrameHeader
Get a mutable reference to the frame’s header.
pub fn into_payload(self) -> Bytes
pub fn into_payload(self) -> Bytes
Consume the frame into its payload.
pub fn message(data: impl Into<Bytes>, opcode: OpCode, is_final: bool) -> Frame
pub fn message(data: impl Into<Bytes>, opcode: OpCode, is_final: bool) -> Frame
Create a new data frame.
pub fn close(msg: Option<CloseFrame>) -> Frame
pub fn close(msg: Option<CloseFrame>) -> Frame
Create a new Close control frame.
pub fn from_payload(header: FrameHeader, payload: Bytes) -> Frame
pub fn from_payload(header: FrameHeader, payload: Bytes) -> Frame
Create a frame from given header and data.
Trait Implementations§
impl Eq for Frame
impl StructuralPartialEq for Frame
Auto Trait Implementations§
impl !Freeze for Frame
impl RefUnwindSafe for Frame
impl Send for Frame
impl Sync for Frame
impl Unpin for Frame
impl UnwindSafe for Frame
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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>
Converts
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>
Converts
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