#[derive(FixedArray)]
{
// Attributes available to this derive:
#[fixed_array]
}
Expand description
Derives byte-array conversion impls for a fixed-size type.
Generates:
TryFrom<[u8; SIZE]>andTryFrom<&[u8; SIZE]>, orFrom<[u8; SIZE]>andFrom<&[u8; SIZE]>wheninfallible(decoding viaDecodeFixed).TryFrom<&[u8]>From<T> for [u8; SIZE]From<&T> for [u8; SIZE]
The type must implement Read<Cfg = ()> and EncodeFixed.
§Attributes
#[fixed_array(infallible)]: emitFrom<[u8; SIZE]>instead ofTryFrom<[u8; SIZE]>. The type’s decode must never fail (any[u8; SIZE]is a valid value), since the generatedFromunwraps theDecodeFixedresult.#[fixed_array(bytes([u8; N]))]: required for any generic type (lifetime, type, or const). Stable Rust forbids a generic parameter inside the const expression[u8; <T as FixedSize>::SIZE], so the byte array type must be named.