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 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 RequestResponseCodec>::Protocol
fn get_req_res_protocol(&self) -> <Self as RequestResponseCodec>::Protocol
Returns RequestResponse’s Protocol
Needed for initialization of RequestResponse Behaviour
source§impl RequestResponseCodec for PostcardCodec
impl RequestResponseCodec 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.
source§fn read_request<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 mut self,
_protocol: &'life1 Self::Protocol,
socket: &'life2 mut T
) -> Pin<Box<dyn Future<Output = Result<Self::Request>> + Send + 'async_trait>>where
T: AsyncRead + Unpin + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn read_request<'life0, 'life1, 'life2, 'async_trait, T>( &'life0 mut self, _protocol: &'life1 Self::Protocol, socket: &'life2 mut T ) -> Pin<Box<dyn Future<Output = Result<Self::Request>> + Send + 'async_trait>>where T: AsyncRead + Unpin + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: '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,
_protocol: &'life1 Self::Protocol,
socket: &'life2 mut T
) -> Pin<Box<dyn Future<Output = Result<Self::Response>> + Send + 'async_trait>>where
T: AsyncRead + Unpin + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn read_response<'life0, 'life1, 'life2, 'async_trait, T>( &'life0 mut self, _protocol: &'life1 Self::Protocol, socket: &'life2 mut T ) -> Pin<Box<dyn Future<Output = Result<Self::Response>> + Send + 'async_trait>>where T: AsyncRead + Unpin + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: '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 RequestResponseConverter for PostcardCodec
impl RequestResponseConverter for PostcardCodec
§type NetworkResponse = NetworkResponse
type NetworkResponse = NetworkResponse
Response that is sent over the network
§type OutboundResponse = OutboundResponse
type OutboundResponse = OutboundResponse
Response that is ready to be converted into NetworkResponse
§type ResponseMessage = ResponseMessage
type ResponseMessage = ResponseMessage
Final Response Message deserialized from IntermediateResponse
fn convert_to_response( &self, inter_msg: &Self::NetworkResponse ) -> Result<Self::ResponseMessage, Error>
fn convert_to_network_response( &self, res_msg: &Self::OutboundResponse ) -> Result<Self::NetworkResponse, Error>
Auto Trait Implementations§
impl RefUnwindSafe for PostcardCodec
impl Send for PostcardCodec
impl Sync for PostcardCodec
impl Unpin for PostcardCodec
impl UnwindSafe for PostcardCodec
Blanket Implementations§
§impl<T> AnyDebug for Twhere
T: Any + Debug,
impl<T> AnyDebug for Twhere T: Any + Debug,
§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