Struct ws_tool::codec::FrameCodec
source · pub struct FrameCodec<S: Read + Write> {
pub stream: S,
pub read_state: FrameReadState,
pub write_state: FrameWriteState,
}
Expand description
recv/send websocket frame
Fields§
§stream: S
underlying transport stream
read_state: FrameReadState
read state
write_state: FrameWriteState
write state
Implementations§
source§impl<S: Read + Write> FrameCodec<S>
impl<S: Read + Write> FrameCodec<S>
sourcepub fn new_with(stream: S, config: FrameConfig) -> Self
pub fn new_with(stream: S, config: FrameConfig) -> Self
construct with stream and 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 send(&mut self, code: OpCode, payload: &[u8]) -> Result<(), WsError>
pub fn send(&mut self, code: OpCode, payload: &[u8]) -> Result<(), WsError>
send data, will copy data if need mask
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
Auto Trait Implementations§
impl<S> RefUnwindSafe for FrameCodec<S>where
S: RefUnwindSafe,
impl<S> Send for FrameCodec<S>where
S: Send,
impl<S> Sync for FrameCodec<S>where
S: Sync,
impl<S> Unpin for FrameCodec<S>where
S: Unpin,
impl<S> UnwindSafe for FrameCodec<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