Trait octseq::octets::OctetsFrom
source · pub trait OctetsFrom<Source>: Sized {
type Error: Into<ShortBuf>;
// Required method
fn try_octets_from(source: Source) -> Result<Self, Self::Error>;
// Provided method
fn octets_from(source: Source) -> Self
where Self::Error: Into<Infallible> { ... }
}
Expand description
Convert a type from one octets type to another.
This trait allows creating a value of a type that is generic over an octets sequence from an identical value using a different type of octets sequence.
This is different from just From
in that the conversion may fail if the
source sequence is longer than the space available for the target type.
Required Associated Types§
Required Methods§
sourcefn try_octets_from(source: Source) -> Result<Self, Self::Error>
fn try_octets_from(source: Source) -> Result<Self, Self::Error>
Performs the conversion.
Provided Methods§
sourcefn octets_from(source: Source) -> Self
fn octets_from(source: Source) -> Self
Performs an infallible conversion.
Object Safety§
This trait is not object safe.