pub trait TypedHeader: Sized {
const NAME: HeaderName;
const VALIDATE_LIST: bool = false;
// Required method
fn decode(value: &[u8]) -> Result<Self, HeaderError>;
// Provided methods
fn decode_list(value: &[u8]) -> Result<Vec<Self>, HeaderError> { ... }
fn validate_list(_values: &[&Self]) -> Result<(), HeaderError> { ... }
}Expand description
A header value that parses into a typed form.
Required Associated Constants§
Sourceconst NAME: HeaderName
const NAME: HeaderName
The header this type reads.
Provided Associated Constants§
Sourceconst VALIDATE_LIST: bool = false
const VALIDATE_LIST: bool = false
Whether Headers::typed_all must collect and validate the complete field before yielding.
The default keeps ordinary headers streaming and allocation-free across rows. A field with
message-wide constraints opts in and implements Self::validate_list.
Required Methods§
Sourcefn decode(value: &[u8]) -> Result<Self, HeaderError>
fn decode(value: &[u8]) -> Result<Self, HeaderError>
Parse one header value. The value arrives unfolded and trimmed.
Provided Methods§
Sourcefn decode_list(value: &[u8]) -> Result<Vec<Self>, HeaderError>
fn decode_list(value: &[u8]) -> Result<Vec<Self>, HeaderError>
Parse every value in one header row.
RFC 3261 §7.3 makes a comma-joined row exactly equivalent to the same values on separate rows for headers whose grammar is a comma-separated list; those headers override this. Everything else carries exactly one value per row.
Sourcefn validate_list(_values: &[&Self]) -> Result<(), HeaderError>
fn validate_list(_values: &[&Self]) -> Result<(), HeaderError>
Validate all decoded values of this field across the complete message.
Most SIP list fields have no message-wide constraint, so the default accepts every
sequence. A field whose grammar constrains the number or relationship of values can
override this; Headers::typed_all calls it after expanding every comma-separated row
and repeated field line into wire order.
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.