pub trait PacketEncoder {
type Error: Error + Send + Sync + 'static;
// Required methods
fn encode_packet<'life0, 'async_trait, T, S>(
&'life0 self,
data: T,
routing: ResolvedTransportRouting,
signals: S,
) -> Pin<Box<dyn Future<Output = Result<OutgoingPacket, Self::Error>> + Send + 'async_trait>>
where T: 'async_trait + AsRef<[u8]> + Send + 'static,
S: 'async_trait + Into<PacketSignals> + Send + 'static,
Self: 'async_trait,
'life0: 'async_trait;
fn encode_acknowledgement<'life0, 'life1, 'async_trait>(
&'life0 self,
ack: VerifiedAcknowledgement,
peer: &'life1 OffchainPublicKey,
) -> Pin<Box<dyn Future<Output = Result<OutgoingPacket, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}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<'life0, 'async_trait, T, S>(
&'life0 self,
data: T,
routing: ResolvedTransportRouting,
signals: S,
) -> Pin<Box<dyn Future<Output = Result<OutgoingPacket, Self::Error>> + Send + 'async_trait>>
fn encode_packet<'life0, 'async_trait, T, S>( &'life0 self, data: T, routing: ResolvedTransportRouting, signals: S, ) -> Pin<Box<dyn Future<Output = Result<OutgoingPacket, Self::Error>> + Send + 'async_trait>>
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_acknowledgement<'life0, 'life1, 'async_trait>(
&'life0 self,
ack: VerifiedAcknowledgement,
peer: &'life1 OffchainPublicKey,
) -> Pin<Box<dyn Future<Output = Result<OutgoingPacket, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn encode_acknowledgement<'life0, 'life1, 'async_trait>(
&'life0 self,
ack: VerifiedAcknowledgement,
peer: &'life1 OffchainPublicKey,
) -> Pin<Box<dyn Future<Output = Result<OutgoingPacket, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Encodes the given VerifiedAcknowledgement as an outgoing packet to be sent to the given
peer.
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.