Struct ws_tool::codec::DeflateCodec
source · pub struct DeflateCodec<S: Read + Write> { /* private fields */ }
Expand description
recv/send deflate message
Implementations§
source§impl<S: Read + Write> DeflateCodec<S>
impl<S: Read + Write> DeflateCodec<S>
sourcepub fn new(
stream: S,
frame_config: FrameConfig,
pmd_config: Option<PMDConfig>,
is_server: bool
) -> Self
pub fn new( stream: S, frame_config: FrameConfig, pmd_config: Option<PMDConfig>, is_server: bool ) -> Self
construct method
sourcepub fn factory(req: Request<()>, stream: S) -> Result<Self, WsError>
pub fn factory(req: Request<()>, stream: S) -> Result<Self, WsError>
used for server side to construct a new server
sourcepub fn check_fn(
key: String,
resp: Response<()>,
stream: S
) -> Result<Self, WsError>
pub fn check_fn( key: String, resp: Response<()>, stream: S ) -> Result<Self, WsError>
used for client side to construct a new client
sourcepub fn stream_mut(&mut self) -> &mut S
pub fn stream_mut(&mut self) -> &mut S
get mutable underlying stream
sourcepub fn send_owned_frame(&mut self, frame: OwnedFrame) -> Result<(), WsError>
pub fn send_owned_frame(&mut self, frame: OwnedFrame) -> Result<(), WsError>
send a read frame, this method will not check validation of frame and do not fragment
sourcepub fn send(&mut self, code: OpCode, payload: &[u8]) -> Result<(), WsError>
pub fn send(&mut self, code: OpCode, payload: &[u8]) -> Result<(), WsError>
send payload
will auto fragment before compression if auto_fragment_size > 0
sourcepub fn binary(&mut self, data: &[u8]) -> Result<(), WsError>
pub fn binary(&mut self, data: &[u8]) -> Result<(), WsError>
helper function to send binary message
sourcepub fn ping(&mut self, data: &[u8]) -> Result<(), WsError>
pub fn ping(&mut self, data: &[u8]) -> Result<(), WsError>
helper function to send ping message
sourcepub fn pong(&mut self, data: &[u8]) -> Result<(), WsError>
pub fn pong(&mut self, data: &[u8]) -> Result<(), WsError>
helper function to send ping message
source§impl<R, W, S> DeflateCodec<S>
impl<R, W, S> DeflateCodec<S>
sourcepub fn split(self) -> (DeflateRecv<R>, DeflateSend<W>)
pub fn split(self) -> (DeflateRecv<R>, DeflateSend<W>)
split codec to recv and send parts
Auto Trait Implementations§
impl<S> RefUnwindSafe for DeflateCodec<S>where
S: RefUnwindSafe,
impl<S> Send for DeflateCodec<S>where
S: Send,
impl<S> Sync for DeflateCodec<S>where
S: Sync,
impl<S> Unpin for DeflateCodec<S>where
S: Unpin,
impl<S> UnwindSafe for DeflateCodec<S>where
S: UnwindSafe,
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