Trait internet2::presentation::sphinx::SphinxPayload
source · [−]pub trait SphinxPayload: LightningEncode + LightningDecode + StrictEncode + StrictDecode + Debug + Clone + Hash + Eq {
type DecodeError: Error;
fn serialized_len(&self) -> usize;
fn encode(&self, writer: impl Write) -> Result<usize, Error>;
fn decode(reader: impl Read) -> Result<Self, Self::DecodeError>
where
Self: Sized;
fn serialize(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
{ ... }
}
Expand description
Sphinx is abstracted from a specific encoding used by a packed payload: it may be BOLT-4 lightning, strict encoding or any other encoding. Specific payload types must implement this trait to provide Internet2 crate with a proper encoding implementation.
Required Associated Types
type DecodeError: Error
type DecodeError: Error
Errors during payload decoding
Required Methods
fn serialized_len(&self) -> usize
fn serialized_len(&self) -> usize
Calculate total size of the payload encoded data.
Must not call SphinxPayload::serialize
otherwise this will result
in infinite call loop.
Encodes payload data into a binary byte stream. Must return number of bytes added to the stream.