Skip to main content

Module array

Module array 

Source
Available on crate feature serde only.
Expand description

Exact-length arrays using the parent module’s prefix and case policy.

Deserialization writes into [u8; N] without an intermediate byte vector. Input text is borrowed where possible; formats may need storage for escaped or transient text. Serialization uses the parent adapter’s string representation, including any framing added by the format.

§Examples

#[derive(Debug, PartialEq, serde::Serialize, serde::Deserialize)]
struct Record {
    #[serde(with = "faster_hex::withpfx_ignorecase::array")]
    id: [u8; 2],
}
let record = Record { id: [0x12, 0x34] };
let json = serde_json::to_string(&record)?;
assert_eq!(serde_json::from_str::<Record>(&json)?, record);

Functions§

deserialize
Deserializes exactly N bytes into an owned array.
serialize
Serializes a byte view using this module’s prefix and case policy.