pub struct HeaderExtension<'a> {
pub het: u8,
pub content: &'a [u8],
}Expand description
One LCT/NORM header extension (RFC 5651 §5.2 / RFC 5740 §4.1).
The content is everything in the extension after the leading HET byte and
(for variable-length extensions) the HEL byte:
- variable-length (
het < 128):content.len()is4*HEL − 2, and may be any length whose total (+2) is a multiple of 4. - fixed-length (
het >= 128):contentis exactly the 3 bytes after HET.
HEL is not stored: it is recomputed from content.len() on serialize,
so the round-trip is driven entirely from the typed fields (no raw
passthrough).
Fields§
§het: u8Header Extension Type.
content: &'a [u8]The extension content bytes (after HET, and after HEL when present).
Implementations§
Source§impl<'a> HeaderExtension<'a>
impl<'a> HeaderExtension<'a>
Sourcepub fn new(het: u8, content: &'a [u8]) -> Self
pub fn new(het: u8, content: &'a [u8]) -> Self
Construct a variable- or fixed-length extension from its HET and content.
Sourcepub fn is_fixed(&self) -> bool
pub fn is_fixed(&self) -> bool
true if this is a fixed-length extension (HET ≥ 128, one 32-bit word).
Sourcepub fn serialized_len(&self) -> usize
pub fn serialized_len(&self) -> usize
Total serialized size in bytes (always a multiple of 4).
Sourcepub fn hel(&self) -> usize
pub fn hel(&self) -> usize
The HEL value as it appears on the wire (whole extension length in
32-bit words). Only meaningful for variable-length extensions.
Sourcepub fn parse(data: &'a [u8]) -> Result<(Self, usize)>
pub fn parse(data: &'a [u8]) -> Result<(Self, usize)>
Parse a single header extension from the start of data. Returns the
extension and the number of bytes consumed.
Sourcepub fn serialize_into(&self, out: &mut [u8]) -> Result<usize>
pub fn serialize_into(&self, out: &mut [u8]) -> Result<usize>
Serialize this extension into out, recomputing HEL from the content
length. Returns the number of bytes written.
Trait Implementations§
Source§impl<'a> Clone for HeaderExtension<'a>
impl<'a> Clone for HeaderExtension<'a>
Source§fn clone(&self) -> HeaderExtension<'a>
fn clone(&self) -> HeaderExtension<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'a> Debug for HeaderExtension<'a>
impl<'a> Debug for HeaderExtension<'a>
impl<'a> Eq for HeaderExtension<'a>
Source§impl<'a> PartialEq for HeaderExtension<'a>
impl<'a> PartialEq for HeaderExtension<'a>
Source§impl<'a> Serialize for HeaderExtension<'a>
Available on crate feature serde only.
impl<'a> Serialize for HeaderExtension<'a>
serde only.