Skip to main content

PacketDecoder

Trait PacketDecoder 

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

    // Required method
    fn decode(
        &self,
        sender: PeerId,
        data: Bytes,
    ) -> Result<IncomingPacket, IncomingPacketError<Self::Error>>;
}
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( &self, sender: PeerId, data: Bytes, ) -> Result<IncomingPacket, IncomingPacketError<Self::Error>>

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( &self, sender: PeerId, data: Bytes, ) -> Result<IncomingPacket, IncomingPacketError<Self::Error>>

Source§

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

Source§

type Error = <T as PacketDecoder>::Error

Source§

fn decode( &self, sender: PeerId, data: Bytes, ) -> Result<IncomingPacket, IncomingPacketError<Self::Error>>

Source§

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

Source§

type Error = <T as PacketDecoder>::Error

Source§

fn decode( &self, sender: PeerId, data: Bytes, ) -> Result<IncomingPacket, IncomingPacketError<Self::Error>>

Implementors§

Source§

impl<Chain, S, T> PacketDecoder for HoprDecoder<Chain, S, T>
where Chain: ChainReadChannelOperations + ChainKeyOperations + ChainReadTicketOperations + ChainValues + Send + Sync, S: SurbStore + Send + Sync + 'static, T: TicketFactory + Send + Sync,