pub struct ChatCodec;Expand description
The codec for the chat protocol.
This codec is used by the libp2p request_response behaviour to encode
and decode chat messages.
Implementations§
Trait Implementations§
Source§impl Codec for ChatCodec
impl Codec for ChatCodec
Source§fn read_request<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 mut self,
_: &'life1 Self::Protocol,
io: &'life2 mut T,
) -> Pin<Box<dyn Future<Output = Result<Self::Request>> + Send + 'async_trait>>
fn read_request<'life0, 'life1, 'life2, 'async_trait, T>( &'life0 mut self, _: &'life1 Self::Protocol, io: &'life2 mut T, ) -> Pin<Box<dyn Future<Output = Result<Self::Request>> + Send + 'async_trait>>
Reads a length-prefixed JSON-encoded request from the given I/O stream.
Source§fn read_response<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 mut self,
_: &'life1 Self::Protocol,
io: &'life2 mut T,
) -> Pin<Box<dyn Future<Output = Result<Self::Response>> + Send + 'async_trait>>
fn read_response<'life0, 'life1, 'life2, 'async_trait, T>( &'life0 mut self, _: &'life1 Self::Protocol, io: &'life2 mut T, ) -> Pin<Box<dyn Future<Output = Result<Self::Response>> + Send + 'async_trait>>
Reads a length-prefixed JSON-encoded response from the given I/O stream.
Source§fn write_request<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 mut self,
_: &'life1 Self::Protocol,
io: &'life2 mut T,
req: Self::Request,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
T: AsyncWrite + Unpin + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn write_request<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 mut self,
_: &'life1 Self::Protocol,
io: &'life2 mut T,
req: Self::Request,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
T: AsyncWrite + Unpin + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Writes a length-prefixed JSON-encoded request to the given I/O stream.
Source§fn write_response<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 mut self,
_: &'life1 Self::Protocol,
io: &'life2 mut T,
res: Self::Response,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
T: AsyncWrite + Unpin + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn write_response<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 mut self,
_: &'life1 Self::Protocol,
io: &'life2 mut T,
res: Self::Response,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
T: AsyncWrite + Unpin + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Writes a length-prefixed JSON-encoded response to the given I/O stream.
Source§type Request = ChatRequest
type Request = ChatRequest
The type of inbound and outbound requests.
Source§type Response = ChatResponse
type Response = ChatResponse
The type of inbound and outbound responses.
Auto Trait Implementations§
impl Freeze for ChatCodec
impl RefUnwindSafe for ChatCodec
impl Send for ChatCodec
impl Sync for ChatCodec
impl Unpin for ChatCodec
impl UnwindSafe for ChatCodec
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more