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§
Required Methods§
Sourcefn decode(
&self,
sender: PeerId,
data: Bytes,
) -> Result<IncomingPacket, IncomingPacketError<Self::Error>>
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.