pub struct StringCodec<S: Read + Write> { /* private fields */ }
Expand description
recv/send text message
Implementations§
Source§impl<S: Read + Write> StringCodec<S>
impl<S: Read + Write> StringCodec<S>
Sourcepub fn new_with(stream: S, config: FrameConfig, validate_utf8: bool) -> Self
pub fn new_with(stream: S, config: FrameConfig, validate_utf8: bool) -> Self
construct with config
Sourcepub fn stream_mut(&mut self) -> &mut S
pub fn stream_mut(&mut self) -> &mut S
get mutable underlying stream
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 to client side to construct a new client
Sourcepub fn receive_raw(&mut self) -> Result<Message<Cow<'_, [u8]>>, WsError>
pub fn receive_raw(&mut self) -> Result<Message<Cow<'_, [u8]>>, WsError>
in case of ping/pong/close contain non utf-8 string, use this api to receive raw message
for close frame with body, first two bytes of string are close reason
Sourcepub fn receive(&mut self) -> Result<Message<Cow<'_, str>>, WsError>
pub fn receive(&mut self) -> Result<Message<Cow<'_, str>>, WsError>
for close frame with body, first two bytes of string are close reason
Sourcepub fn ping<'a>(&mut self, msg: &'a str) -> Result<(), WsError>
pub fn ping<'a>(&mut self, msg: &'a str) -> Result<(), WsError>
helper method to send ping message
Sourcepub fn pong<'a>(&mut self, msg: &'a str) -> Result<(), WsError>
pub fn pong<'a>(&mut self, msg: &'a str) -> Result<(), WsError>
helper method to send pong message
Sourcepub fn close<'a>(&mut self, code: u16, msg: &'a str) -> Result<(), WsError>
pub fn close<'a>(&mut self, code: u16, msg: &'a str) -> Result<(), WsError>
helper method to send close message
Source§impl<R, W, S> StringCodec<S>
impl<R, W, S> StringCodec<S>
Sourcepub fn split(self) -> (StringRecv<R>, StringSend<W>)
pub fn split(self) -> (StringRecv<R>, StringSend<W>)
split codec to recv and send parts
Auto Trait Implementations§
impl<S> Freeze for StringCodec<S>where
S: Freeze,
impl<S> RefUnwindSafe for StringCodec<S>where
S: RefUnwindSafe,
impl<S> Send for StringCodec<S>where
S: Send,
impl<S> Sync for StringCodec<S>where
S: Sync,
impl<S> Unpin for StringCodec<S>where
S: Unpin,
impl<S> UnwindSafe for StringCodec<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