pub trait PacketEncoder {
type Error: Error + Send + Sync + 'static;
// Required methods
fn encode_packet<T: AsRef<[u8]> + Send + 'static, S: Into<PacketSignals> + Send + 'static>(
&self,
data: T,
routing: ResolvedTransportRouting<HoprSurb>,
signals: S,
) -> Result<OutgoingPacket, Self::Error>;
fn encode_acknowledgements(
&self,
acks: &[VerifiedAcknowledgement],
destination: &OffchainPublicKey,
) -> Result<OutgoingPacket, Self::Error>;
}Expand description
Trait defining encoder for outgoing HOPR packets.
These operations are done directly by the packet processing pipeline before the outgoing packet is handled to the underlying p2p transport.
Required Associated Types§
Required Methods§
Sourcefn encode_packet<T: AsRef<[u8]> + Send + 'static, S: Into<PacketSignals> + Send + 'static>(
&self,
data: T,
routing: ResolvedTransportRouting<HoprSurb>,
signals: S,
) -> Result<OutgoingPacket, Self::Error>
fn encode_packet<T: AsRef<[u8]> + Send + 'static, S: Into<PacketSignals> + Send + 'static>( &self, data: T, routing: ResolvedTransportRouting<HoprSurb>, signals: S, ) -> Result<OutgoingPacket, Self::Error>
Encodes the given data and signals for sending.
The data MUST be already correctly sized for HOPR packets, otherwise the operation
must fail.
Sourcefn encode_acknowledgements(
&self,
acks: &[VerifiedAcknowledgement],
destination: &OffchainPublicKey,
) -> Result<OutgoingPacket, Self::Error>
fn encode_acknowledgements( &self, acks: &[VerifiedAcknowledgement], destination: &OffchainPublicKey, ) -> Result<OutgoingPacket, Self::Error>
Encodes the given vector of VerifiedAcknowledgements as an outgoing packet to be
sent to the given destination.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.