pub struct MessageCodec<S: Read + Write> { /* private fields */ }
Expand description
protocol message reader/writer
Implementations§
Source§impl<S: Read + Write> MessageCodec<S>
impl<S: Read + Write> MessageCodec<S>
pub fn new(stream: S) -> Self
Sourcepub fn stream_mut(&mut self) -> &mut S
pub fn stream_mut(&mut self) -> &mut S
get mutable ref of underlying stream
Sourcepub fn receive(
&mut self,
) -> Result<OneOf3<RequestMessage, ResponseMessage, NotificationMessage>>
pub fn receive( &mut self, ) -> Result<OneOf3<RequestMessage, ResponseMessage, NotificationMessage>>
read message from peer
for server, most of times coming messages are request or notification, at some rare case, there maybe a response, see applyEdit
Sourcepub fn send(
&mut self,
message: OneOf3<RequestMessage, ResponseMessage, NotificationMessage>,
) -> Result<()>
pub fn send( &mut self, message: OneOf3<RequestMessage, ResponseMessage, NotificationMessage>, ) -> Result<()>
write message to peer
Sourcepub fn send_req(&mut self, message: RequestMessage) -> Result<()>
pub fn send_req(&mut self, message: RequestMessage) -> Result<()>
helper function to send request only
Sourcepub fn send_resp(&mut self, message: ResponseMessage) -> Result<()>
pub fn send_resp(&mut self, message: ResponseMessage) -> Result<()>
helper function to send response only
Sourcepub fn send_notice(&mut self, message: NotificationMessage) -> Result<()>
pub fn send_notice(&mut self, message: NotificationMessage) -> Result<()>
helper function to send notification only
Auto Trait Implementations§
impl<S> Freeze for MessageCodec<S>where
S: Freeze,
impl<S> RefUnwindSafe for MessageCodec<S>where
S: RefUnwindSafe,
impl<S> Send for MessageCodec<S>where
S: Send,
impl<S> Sync for MessageCodec<S>where
S: Sync,
impl<S> Unpin for MessageCodec<S>where
S: Unpin,
impl<S> UnwindSafe for MessageCodec<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