Struct ws_tool::codec::StringCodec
source · 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(&mut self) -> Result<Message<String>, WsError>
pub fn receive(&mut self) -> Result<Message<String>, WsError>
for close frame with body, first two bytes of string are close reason
source§impl<R, W, S> StringCodec<S>where
R: Read,
W: Write,
S: Read + Write + Split<R = R, W = W>,
impl<R, W, S> StringCodec<S>where R: Read, W: Write, S: Read + Write + Split<R = R, W = W>,
sourcepub fn split(self) -> (StringRecv<R>, StringSend<W>)
pub fn split(self) -> (StringRecv<R>, StringSend<W>)
split codec to recv and send parts