pub trait TryFromByteArray: IntoByteArray {
// Required method
fn try_from_byte_array(
byte_array: Self::ByteArray,
) -> Result<Self, DecodeError>;
}Expand description
Fallible conversion from a fixed-size byte array back into a value.
Use this when decoding can fail (e.g. bool, char, NonZero<T>). Returns
DecodeError on failure.
For types that implement FromByteArray, a blanket impl provides TryFromByteArray
automatically by wrapping the infallible conversion in Ok(...).
§Errors
Returns DecodeError if the byte array does not represent a valid value of Self.
Required Methods§
Sourcefn try_from_byte_array(byte_array: Self::ByteArray) -> Result<Self, DecodeError>
fn try_from_byte_array(byte_array: Self::ByteArray) -> Result<Self, DecodeError>
Attempt to deserialize a value from a fixed-size byte array.
§Errors
Returns DecodeError if the bytes are not a valid encoding of Self.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.