Trait octseq::octets::OctetsInto

source ·
pub trait OctetsInto<Target>: Sized {
    type Error: Into<ShortBuf>;

    // Required method
    fn try_octets_into(self) -> Result<Target, Self::Error>;

    // Provided method
    fn octets_into(self) -> Target
       where Self::Error: Into<Infallible> { ... }
}
Expand description

Convert a type from one octets type to another.

This trait allows trading in a value of a type that is generic over an octets sequence for an identical value using a different type of octets sequence.

This is different from just Into in that the conversion may fail if the source sequence is longer than the space available for the target type.

This trait has a blanket implementation for all pairs of types where OctetsFrom has been implemented.

Required Associated Types§

Required Methods§

source

fn try_octets_into(self) -> Result<Target, Self::Error>

Performs the conversion.

Provided Methods§

source

fn octets_into(self) -> Target
where Self::Error: Into<Infallible>,

Performs an infallible conversion.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<Source, Target: OctetsFrom<Source>> OctetsInto<Target> for Source

§

type Error = <Target as OctetsFrom<Source>>::Error