pub enum HoprPacket {
Final(Box<HoprIncomingPacket>),
Forwarded(Box<HoprForwardedPacket>),
Outgoing(Box<HoprOutgoingPacket>),
}Expand description
Contains HOPR packet and its variants.
See HoprIncomingPacket, HoprForwardedPacket and HoprOutgoingPacket for details.
The members are intentionally boxed to equalize the variant sizes.
Variants§
Final(Box<HoprIncomingPacket>)
The packet is intended for us
Forwarded(Box<HoprForwardedPacket>)
The packet must be forwarded
Outgoing(Box<HoprOutgoingPacket>)
The packet that is being sent out by us
Implementations§
Source§impl HoprPacket
impl HoprPacket
pub fn try_as_final(self) -> Option<Box<HoprIncomingPacket>>
pub const fn try_as_final_ref(&self) -> Option<&Box<HoprIncomingPacket>>
pub fn try_as_final_mut(&mut self) -> Option<&mut Box<HoprIncomingPacket>>
pub fn try_as_forwarded(self) -> Option<Box<HoprForwardedPacket>>
pub const fn try_as_forwarded_ref(&self) -> Option<&Box<HoprForwardedPacket>>
pub fn try_as_forwarded_mut(&mut self) -> Option<&mut Box<HoprForwardedPacket>>
pub fn try_as_outgoing(self) -> Option<Box<HoprOutgoingPacket>>
pub const fn try_as_outgoing_ref(&self) -> Option<&Box<HoprOutgoingPacket>>
pub fn try_as_outgoing_mut(&mut self) -> Option<&mut Box<HoprOutgoingPacket>>
Source§impl HoprPacket
impl HoprPacket
Sourcepub const fn is_final(&self) -> bool
pub const fn is_final(&self) -> bool
Returns true if the enum is HoprPacket::Final otherwise false
Sourcepub const fn is_forwarded(&self) -> bool
pub const fn is_forwarded(&self) -> bool
Returns true if the enum is HoprPacket::Forwarded otherwise false
Sourcepub const fn is_outgoing(&self) -> bool
pub const fn is_outgoing(&self) -> bool
Returns true if the enum is HoprPacket::Outgoing otherwise false
Source§impl HoprPacket
impl HoprPacket
Sourcepub fn packet_tag(&self) -> Option<&PacketTag>
pub fn packet_tag(&self) -> Option<&PacketTag>
Returns the [PacketTag] of forwarded or final packets, or None for outgoing packets.
Source§impl HoprPacket
impl HoprPacket
Sourcepub const MAX_SURBS_IN_PACKET: usize
pub const MAX_SURBS_IN_PACKET: usize
The maximum number of SURBs that fit into a packet that contains no message.
Sourcepub const PAYLOAD_SIZE: usize
pub const PAYLOAD_SIZE: usize
Maximum message size when no SURBs are present in the packet.
Sourcepub const SIZE: usize
pub const SIZE: usize
The size of the packet including header, padded payload, ticket, and ack challenge.
Sourcepub fn into_outgoing<M: ProtocolKeyIdMapper<HoprSphinxSuite, HoprSphinxHeaderSpec>, P: NonEmptyPath<OffchainPublicKey> + Send, S: Into<PacketSignals>>(
msg: &[u8],
pseudonym: &HoprPseudonym,
routing: PacketRouting<P>,
chain_keypair: &ChainKeypair,
ticket: TicketBuilder,
mapper: &M,
domain_separator: &Hash,
signals: S,
) -> Result<(Self, Vec<HoprReplyOpener>)>
pub fn into_outgoing<M: ProtocolKeyIdMapper<HoprSphinxSuite, HoprSphinxHeaderSpec>, P: NonEmptyPath<OffchainPublicKey> + Send, S: Into<PacketSignals>>( msg: &[u8], pseudonym: &HoprPseudonym, routing: PacketRouting<P>, chain_keypair: &ChainKeypair, ticket: TicketBuilder, mapper: &M, domain_separator: &Hash, signals: S, ) -> Result<(Self, Vec<HoprReplyOpener>)>
Constructs a new outgoing packet with the given path.
§Arguments
msgpacket payload.pseudonymour pseudonym as packet sender.routingrouting to the destination.chain_keypairprivate key of the local node.ticketticket builder for the first hop on the path.mapperof the public key identifiers.domain_separatorchannels contract domain separator.signalsoptional signals passed to the packet’s final destination.
NOTE
For the given pseudonym, the ReplyOpener order matters.
Sourcepub const fn max_surbs_with_message(msg_len: usize) -> usize
pub const fn max_surbs_with_message(msg_len: usize) -> usize
Calculates how many SURBs can be fitted into a packet that also carries a message of the given length.
Sourcepub const fn max_message_with_surbs(num_surbs: usize) -> usize
pub const fn max_message_with_surbs(num_surbs: usize) -> usize
Calculates the maximum length of the message that can be carried by a packet with the given number of SURBs.
Sourcepub fn from_incoming<M, F>(
data: &[u8],
node_keypair: &OffchainKeypair,
previous_hop: OffchainPublicKey,
mapper: &M,
reply_openers: F,
) -> Result<Self>where
M: ProtocolKeyIdMapper<HoprSphinxSuite, HoprSphinxHeaderSpec>,
F: FnMut(&HoprSenderId) -> Option<ReplyOpener>,
pub fn from_incoming<M, F>(
data: &[u8],
node_keypair: &OffchainKeypair,
previous_hop: OffchainPublicKey,
mapper: &M,
reply_openers: F,
) -> Result<Self>where
M: ProtocolKeyIdMapper<HoprSphinxSuite, HoprSphinxHeaderSpec>,
F: FnMut(&HoprSenderId) -> Option<ReplyOpener>,
Deserializes the packet and performs the forward-transformation, so the packet can be further delivered (relayed to the next hop or read).
Trait Implementations§
Source§impl Clone for HoprPacket
impl Clone for HoprPacket
Source§fn clone(&self) -> HoprPacket
fn clone(&self) -> HoprPacket
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for HoprPacket
impl Debug for HoprPacket
Auto Trait Implementations§
impl Freeze for HoprPacket
impl RefUnwindSafe for HoprPacket
impl Send for HoprPacket
impl Sync for HoprPacket
impl Unpin for HoprPacket
impl UnwindSafe for HoprPacket
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.