PacketDecoder

Trait PacketDecoder 

Source
pub trait PacketDecoder {
    type Error: Error + Send + Sync + 'static;

    // Required method
    fn decode<'life0, 'async_trait>(
        &'life0 self,
        sender: PeerId,
        data: Box<[u8]>,
    ) -> Pin<Box<dyn Future<Output = Result<IncomingPacket, IncomingPacketError<Self::Error>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Trait defining decoder HOPR packets.

This operation is done directly by the packet processing pipeline after the underlying p2p transport hands over incoming data packets.

Required Associated Types§

Source

type Error: Error + Send + Sync + 'static

Required Methods§

Source

fn decode<'life0, 'async_trait>( &'life0 self, sender: PeerId, data: Box<[u8]>, ) -> Pin<Box<dyn Future<Output = Result<IncomingPacket, IncomingPacketError<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Decodes the data received from the given sender returns the corresponding IncomingPacket if the decoding into a HOPR packet was successful.

Implementations on Foreign Types§

Source§

impl<'a, T: 'a + PacketDecoder + ?Sized> PacketDecoder for &'a T

Source§

type Error = <T as PacketDecoder>::Error

Source§

fn decode<'life0, 'async_trait>( &'life0 self, sender: PeerId, data: Box<[u8]>, ) -> Pin<Box<dyn Future<Output = Result<IncomingPacket, IncomingPacketError<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

impl<T: PacketDecoder + ?Sized> PacketDecoder for Box<T>

Source§

type Error = <T as PacketDecoder>::Error

Source§

fn decode<'life0, 'async_trait>( &'life0 self, sender: PeerId, data: Box<[u8]>, ) -> Pin<Box<dyn Future<Output = Result<IncomingPacket, IncomingPacketError<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

impl<T: PacketDecoder + ?Sized> PacketDecoder for Arc<T>

Source§

type Error = <T as PacketDecoder>::Error

Source§

fn decode<'life0, 'async_trait>( &'life0 self, sender: PeerId, data: Box<[u8]>, ) -> Pin<Box<dyn Future<Output = Result<IncomingPacket, IncomingPacketError<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Implementors§