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,
generation: Option<u8>,
) -> 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,
generation: Option<u8>,
) -> 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, generation: Option<u8>, ) -> 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.
generation is the SURB-batch generation to stamp onto SURBs minted for a forward packet’s
return paths, captured when those return paths were resolved (see
PathPlanner::resolve_routing). It must be captured
with the plan rather than read here, so a concurrent return-path re-plan cannot label an
already-chosen batch with a newer generation. None (no return path, or a non-forward
packet) falls back to the store’s current generation.
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".