Skip to main content

serialize

Function serialize 

Source
pub fn serialize<S, T>(
    data: &Option<T>,
    serializer: S,
) -> Result<S::Ok, S::Error>
where S: Serializer, T: AsRef<[u8]>,
Available on crate feature serde only.
Expand description

Serializes an optional byte view, preserving Serde’s Option tags.

Present values use this module’s hex string policy and read AsRef::as_ref once. None uses the format’s absent-value representation. Allocation behavior matches crate::serialize.

§Errors

Propagates serializer errors, including errors writing an Option tag. Present values also fail if their encoded length overflows.

§Panics

Panics if temporary output storage would exceed isize::MAX bytes.

§Examples

See the module example.