Struct ws_tool::frame::OwnedFrame
source · pub struct OwnedFrame { /* private fields */ }
Expand description
owned frame
Implementations§
source§impl OwnedFrame
impl OwnedFrame
sourcepub fn new(code: OpCode, mask: impl Into<Option<[u8; 4]>>, data: &[u8]) -> Self
pub fn new(code: OpCode, mask: impl Into<Option<[u8; 4]>>, data: &[u8]) -> Self
construct new owned frame
sourcepub fn with_raw(header: Header, payload: BytesMut) -> Self
pub fn with_raw(header: Header, payload: BytesMut) -> Self
use constructed header and payload
NOTE: this will not check header and payload
sourcepub fn text_frame(mask: impl Into<Option<[u8; 4]>>, data: &str) -> Self
pub fn text_frame(mask: impl Into<Option<[u8; 4]>>, data: &str) -> Self
helper function to construct a text frame
sourcepub fn binary_frame(mask: impl Into<Option<[u8; 4]>>, data: &[u8]) -> Self
pub fn binary_frame(mask: impl Into<Option<[u8; 4]>>, data: &[u8]) -> Self
helper function to construct a binary frame
sourcepub fn ping_frame(mask: impl Into<Option<[u8; 4]>>, data: &[u8]) -> Self
pub fn ping_frame(mask: impl Into<Option<[u8; 4]>>, data: &[u8]) -> Self
helper function to construct a ping frame
sourcepub fn pong_frame(mask: impl Into<Option<[u8; 4]>>, data: &[u8]) -> Self
pub fn pong_frame(mask: impl Into<Option<[u8; 4]>>, data: &[u8]) -> Self
helper function to construct a pong frame
sourcepub fn close_frame(
mask: impl Into<Option<[u8; 4]>>,
code: impl Into<Option<u16>>,
data: &[u8]
) -> Self
pub fn close_frame( mask: impl Into<Option<[u8; 4]>>, code: impl Into<Option<u16>>, data: &[u8] ) -> Self
helper function to construct a close frame
sourcepub fn mask(&mut self, mask: [u8; 4])
pub fn mask(&mut self, mask: [u8; 4])
mask frame with provide mask key
this will override old mask
sourcepub fn extend_from_slice(&mut self, data: &[u8])
pub fn extend_from_slice(&mut self, data: &[u8])
extend frame payload
NOTE this function will unmask first, and then extend payload, mask with old mask key finally
sourcepub fn header_mut(&mut self) -> &mut Header
pub fn header_mut(&mut self) -> &mut Header
get mutable frame header
Trait Implementations§
source§impl Clone for OwnedFrame
impl Clone for OwnedFrame
source§fn clone(&self) -> OwnedFrame
fn clone(&self) -> OwnedFrame
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl RefUnwindSafe for OwnedFrame
impl Send for OwnedFrame
impl Sync for OwnedFrame
impl Unpin for OwnedFrame
impl UnwindSafe for OwnedFrame
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