Struct fuel_core_p2p::codecs::postcard::PostcardCodec
source · pub struct PostcardCodec { /* private fields */ }
Implementations§
Trait Implementations§
source§impl Clone for PostcardCodec
impl Clone for PostcardCodec
source§fn clone(&self) -> PostcardCodec
fn clone(&self) -> PostcardCodec
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Codec for PostcardCodec
impl Codec for PostcardCodec
Since Postcard does not support async reads or writes out of the box We prefix Request & Response Messages with the length of the data in bytes We expect the substream to be properly closed when response channel is dropped. Since the request protocol used here expects a response, the sender considers this early close as a protocol violation which results in the connection being closed. If the substream was not properly closed when dropped, the sender would instead run into a timeout waiting for the response.
§type Protocol = MessageExchangePostcardProtocol
type Protocol = MessageExchangePostcardProtocol
The type of protocol(s) or protocol versions being negotiated.
§type Request = RequestMessage
type Request = RequestMessage
The type of inbound and outbound requests.
§type Response = ResponseMessage
type Response = ResponseMessage
The type of inbound and outbound responses.
source§fn read_request<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 mut self,
_: &'life1 Self::Protocol,
socket: &'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, socket: &'life2 mut T, ) -> Pin<Box<dyn Future<Output = Result<Self::Request>> + Send + 'async_trait>>
Reads a request from the given I/O stream according to the
negotiated protocol.
source§fn read_response<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 mut self,
_: &'life1 Self::Protocol,
socket: &'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, socket: &'life2 mut T, ) -> Pin<Box<dyn Future<Output = Result<Self::Response>> + Send + 'async_trait>>
Reads a response from the given I/O stream according to the
negotiated protocol.
source§fn write_request<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 mut self,
_protocol: &'life1 Self::Protocol,
socket: &'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,
_protocol: &'life1 Self::Protocol,
socket: &'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 request to the given I/O stream according to the
negotiated protocol.
source§fn write_response<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 mut self,
_protocol: &'life1 Self::Protocol,
socket: &'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,
_protocol: &'life1 Self::Protocol,
socket: &'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 response to the given I/O stream according to the
negotiated protocol.
source§impl Debug for PostcardCodec
impl Debug for PostcardCodec
source§impl GossipsubCodec for PostcardCodec
impl GossipsubCodec for PostcardCodec
type RequestMessage = GossipsubBroadcastRequest
type ResponseMessage = GossipsubMessage
fn encode(&self, data: Self::RequestMessage) -> Result<Vec<u8>, Error>
fn decode( &self, encoded_data: &[u8], gossipsub_tag: GossipTopicTag, ) -> Result<Self::ResponseMessage, Error>
source§impl NetworkCodec for PostcardCodec
impl NetworkCodec for PostcardCodec
source§fn get_req_res_protocol(&self) -> <Self as Codec>::Protocol
fn get_req_res_protocol(&self) -> <Self as Codec>::Protocol
Returns RequestResponse’s Protocol
Needed for initialization of RequestResponse Behaviour
Auto Trait Implementations§
impl Freeze for PostcardCodec
impl RefUnwindSafe for PostcardCodec
impl Send for PostcardCodec
impl Sync for PostcardCodec
impl Unpin for PostcardCodec
impl UnwindSafe for PostcardCodec
Blanket Implementations§
source§impl<T> AnyDebug for T
impl<T> AnyDebug for T
source§fn as_any_ref(&self) -> &(dyn Any + 'static)
fn as_any_ref(&self) -> &(dyn Any + 'static)
Returns a reference to the underlying type as
Any
.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> 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 moresource§impl<S> IteratorOverTable for S
impl<S> IteratorOverTable for S
source§fn iter_all<M>(
&self,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>where
M: Mappable,
Self: IterableTable<M>,
fn iter_all<M>(
&self,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>where
M: Mappable,
Self: IterableTable<M>,
Returns an iterator over the all entries in the table.
source§fn iter_all_by_prefix<M, P>(
&self,
prefix: Option<P>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>
fn iter_all_by_prefix<M, P>( &self, prefix: Option<P>, ) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>
Returns an iterator over the all entries in the table with the specified prefix.
source§fn iter_all_by_start<M>(
&self,
start: Option<&<M as Mappable>::Key>,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>where
M: Mappable,
Self: IterableTable<M>,
fn iter_all_by_start<M>(
&self,
start: Option<&<M as Mappable>::Key>,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>where
M: Mappable,
Self: IterableTable<M>,
Returns an iterator over the all entries in the table after a specific start key.
source§fn iter_all_filtered<M, P>(
&self,
prefix: Option<P>,
start: Option<&<M as Mappable>::Key>,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>
fn iter_all_filtered<M, P>( &self, prefix: Option<P>, start: Option<&<M as Mappable>::Key>, direction: Option<IterDirection>, ) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>
Returns an iterator over the all entries in the table with a prefix after a specific start key.