pub struct MetaPacket<S, H, const P: usize> { /* private fields */ }
Expand description
An encrypted packet with a payload of size P
.
The final packet size is given by MetaPacket::SIZE
.
A sender can create a new packet via MetaPacket::new
and send it.
Once received by the recipient, it is parsed first by calling MetaPacket::try_from
and then it can be transformed into ForwardedMetaPacket
by calling
the MetaPacket::into_forwarded
method. The ForwardedMetaPacket
then contains the information
about the next recipient of this packet or the payload for the final destination.
The packet format is directly dependent on the used SphinxSuite
.
Implementations§
Source§impl<S: SphinxSuite, H: SphinxHeaderSpec, const P: usize> MetaPacket<S, H, P>
impl<S: SphinxSuite, H: SphinxHeaderSpec, const P: usize> MetaPacket<S, H, P>
Sourcepub const PACKET_LEN: usize
pub const PACKET_LEN: usize
The fixed length of the padded packet.
Sourcepub fn new<M: KeyIdMapper<S, H>>(
payload: PaddedPayload<P>,
routing: MetaPacketRouting<'_, S, H>,
key_mapper: &M,
) -> Result<Self, SphinxError>
pub fn new<M: KeyIdMapper<S, H>>( payload: PaddedPayload<P>, routing: MetaPacketRouting<'_, S, H>, key_mapper: &M, ) -> Result<Self, SphinxError>
Creates a new outgoing packet with the given payload msg
and routing
.
The size of the msg
must be less or equal P
, otherwise the
constructor will return an error.
Sourcepub fn into_forwarded<K, F>(
self,
node_keypair: &S::P,
key_mapper: &K,
reply_openers: F,
) -> Result<ForwardedMetaPacket<S, H, P>, SphinxError>
pub fn into_forwarded<K, F>( self, node_keypair: &S::P, key_mapper: &K, reply_openers: F, ) -> Result<ForwardedMetaPacket<S, H, P>, SphinxError>
Attempts to remove the layer of encryption in this packet by using the given node_keypair
.
This will transform this packet into the ForwardedMetaPacket
.
Trait Implementations§
Source§impl<S: SphinxSuite, H: SphinxHeaderSpec, const P: usize> AsRef<[u8]> for MetaPacket<S, H, P>
impl<S: SphinxSuite, H: SphinxHeaderSpec, const P: usize> AsRef<[u8]> for MetaPacket<S, H, P>
Source§impl<S: SphinxSuite, H: SphinxHeaderSpec, const P: usize> BytesRepresentable for MetaPacket<S, H, P>
impl<S: SphinxSuite, H: SphinxHeaderSpec, const P: usize> BytesRepresentable for MetaPacket<S, H, P>
Source§impl<S, H, const P: usize> Clone for MetaPacket<S, H, P>
impl<S, H, const P: usize> Clone for MetaPacket<S, H, P>
Source§impl<S: SphinxSuite, H: SphinxHeaderSpec, const P: usize> Debug for MetaPacket<S, H, P>
impl<S: SphinxSuite, H: SphinxHeaderSpec, const P: usize> Debug for MetaPacket<S, H, P>
Auto Trait Implementations§
impl<S, H, const P: usize> Freeze for MetaPacket<S, H, P>
impl<S, H, const P: usize> RefUnwindSafe for MetaPacket<S, H, P>where
S: RefUnwindSafe,
H: RefUnwindSafe,
impl<S, H, const P: usize> Send for MetaPacket<S, H, P>
impl<S, H, const P: usize> Sync for MetaPacket<S, H, P>
impl<S, H, const P: usize> Unpin for MetaPacket<S, H, P>
impl<S, H, const P: usize> UnwindSafe for MetaPacket<S, H, P>where
S: UnwindSafe,
H: UnwindSafe,
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> 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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ToHex for Twhere
T: BytesRepresentable,
impl<T> ToHex for Twhere
T: BytesRepresentable,
Source§impl<T> ToHex for T
impl<T> ToHex for T
Source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
self
into the result. Lower case
letters are used (e.g. f9b4ca
)Source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
self
into the result. Upper case
letters are used (e.g. F9B4CA
)§impl<T> ToHex for T
impl<T> ToHex for T
§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
ToHexExt
insteadself
into the result.
Lower case letters are used (e.g. f9b4ca
).§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
ToHexExt
insteadself
into the result.
Upper case letters are used (e.g. F9B4CA
).§impl<T> ToHexExt for T
impl<T> ToHexExt for T
§fn encode_hex(&self) -> String
fn encode_hex(&self) -> String
self
into the result.
Lower case letters are used (e.g. f9b4ca
).§fn encode_hex_upper(&self) -> String
fn encode_hex_upper(&self) -> String
self
into the result.
Upper case letters are used (e.g. F9B4CA
).§fn encode_hex_with_prefix(&self) -> String
fn encode_hex_with_prefix(&self) -> String
self
into the result with prefix 0x
.
Lower case letters are used (e.g. 0xf9b4ca
).§fn encode_hex_upper_with_prefix(&self) -> String
fn encode_hex_upper_with_prefix(&self) -> String
self
into the result with prefix 0X
.
Upper case letters are used (e.g. 0xF9B4CA
).