pub struct PostcardCodec { /* private fields */ }

Implementations§

source§

impl PostcardCodec

source

pub fn new(max_block_size: usize) -> Self

Trait Implementations§

source§

impl Clone for PostcardCodec

source§

fn clone(&self) -> PostcardCodec

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for PostcardCodec

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl GossipsubCodec for PostcardCodec

§

type RequestMessage = GossipsubBroadcastRequest

§

type ResponseMessage = GossipsubMessage

source§

fn encode(&self, data: Self::RequestMessage) -> Result<Vec<u8>, Error>

source§

fn decode( &self, encoded_data: &[u8], gossipsub_tag: GossipTopicTag ) -> Result<Self::ResponseMessage, Error>

source§

impl NetworkCodec for PostcardCodec

source§

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

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

The type of protocol(s) or protocol versions being negotiated.
§

type Request = RequestMessage

The type of inbound and outbound requests.
§

type Response = NetworkResponse

The type of inbound and outbound responses.
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,

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,

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,

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,

Writes a response to the given I/O stream according to the negotiated protocol.
source§

impl RequestResponseConverter for PostcardCodec

§

type NetworkResponse = NetworkResponse

Response that is sent over the network
§

type OutboundResponse = OutboundResponse

Response that is ready to be converted into NetworkResponse
§

type ResponseMessage = ResponseMessage

Final Response Message deserialized from IntermediateResponse
source§

fn convert_to_response( &self, inter_msg: &Self::NetworkResponse ) -> Result<Self::ResponseMessage, Error>

source§

fn convert_to_network_response( &self, res_msg: &Self::OutboundResponse ) -> Result<Self::NetworkResponse, Error>

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AnyDebug for Twhere T: Any + Debug,

§

fn as_any_ref(&self) -> &(dyn Any + 'static)

Returns a reference to the underlying type as Any.
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
§

impl<T> StorageAsMut for T

§

fn storage<Type>(&mut self) -> StorageMut<'_, Self, Type>where Type: Mappable,

§

fn storage_as_mut<Type>(&mut self) -> StorageMut<'_, Self, Type>where Type: Mappable,

§

impl<T> StorageAsRef for T

§

fn storage<Type>(&self) -> StorageRef<'_, Self, Type>where Type: Mappable,

§

fn storage_as_ref<Type>(&self) -> StorageRef<'_, Self, Type>where Type: Mappable,

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more