Trait internet2::presentation::sphinx::SphinxPayload
source · pub trait SphinxPayload: LightningEncode + LightningDecode + StrictEncode + StrictDecode + Debug + Clone + Hash + Eq {
type DecodeError: Error;
// Required methods
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;
// Provided method
fn serialize(&self) -> Vec<u8> ⓘ { ... }
}
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§
sourcetype DecodeError: Error
type DecodeError: Error
Errors during payload decoding
Required Methods§
sourcefn 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.