pub trait HeaderCodec: Sized {
const TYPE_ID: &'static str;
const HEADER_NAME: &'static str;
const JAVA_CLASS: Option<&'static str>;
const FIELD_COUNT_HINT: usize;
const LOCAL_FIELD_SPECS: &'static [HeaderFieldSpec];
const LOCAL_FLATTEN_SPECS: &'static [HeaderFlattenSpec];
const FAST_ENABLED: bool;
// Required methods
fn validate_for_wire(&self) -> Result<(), ProtocolContractViolation>;
fn encode_into<S: EncodeSink>(
&self,
sink: &mut S,
) -> Result<(), ProtocolContractViolation>;
fn decode_from_map(
map: &HeaderMap,
) -> Result<Self, ProtocolContractViolation>;
fn contains_any_field(map: &HeaderMap) -> bool;
fn encoded_len_hint(&self) -> usize;
fn visit_field_specs(visitor: &mut dyn FnMut(&HeaderFieldSpec));
fn visit_flatten_specs(visitor: &mut dyn FnMut(&HeaderFlattenSpec));
fn resolve_wire_key(key: &str) -> Option<ResolvedHeaderKey>;
// Provided methods
fn decode_from_source(
source: &dyn HeaderFieldSource,
) -> Result<Self, ProtocolContractViolation> { ... }
fn contains_any_field_source(source: &dyn HeaderFieldSource) -> bool { ... }
fn canonical_wire_key(key: &str) -> Option<&'static str> { ... }
fn contains_wire_key(key: &str) -> bool { ... }
}Expand description
Statically dispatched codec contract for an explicit request-header schema.
Implementations are generated by RequestHeaderCodec. Map and binary
destinations share Self::encode_into, so validation, canonical keys,
Java ranges, flattening, and value conversion cannot diverge by format.
Required Associated Constants§
Sourceconst HEADER_NAME: &'static str
const HEADER_NAME: &'static str
Rust header name used in diagnostics.
Sourceconst JAVA_CLASS: Option<&'static str>
const JAVA_CLASS: Option<&'static str>
Fully qualified Java peer when one is declared.
Sourceconst FIELD_COUNT_HINT: usize
const FIELD_COUNT_HINT: usize
Recursive upper bound used to reserve map entries.
Sourceconst LOCAL_FIELD_SPECS: &'static [HeaderFieldSpec]
const LOCAL_FIELD_SPECS: &'static [HeaderFieldSpec]
Fields declared directly by this header, in stable binary order.
Sourceconst LOCAL_FLATTEN_SPECS: &'static [HeaderFlattenSpec]
const LOCAL_FLATTEN_SPECS: &'static [HeaderFlattenSpec]
Flatten groups declared directly by this header, in stable binary order.
Sourceconst FAST_ENABLED: bool
const FAST_ENABLED: bool
Whether direct binary generation was requested for the schema.
Required Methods§
Sourcefn validate_for_wire(&self) -> Result<(), ProtocolContractViolation>
fn validate_for_wire(&self) -> Result<(), ProtocolContractViolation>
Validates this header layer before it writes to a wire destination.
§Errors
Returns a classified structural or header-specific validation failure.
Sourcefn encode_into<S: EncodeSink>(
&self,
sink: &mut S,
) -> Result<(), ProtocolContractViolation>
fn encode_into<S: EncodeSink>( &self, sink: &mut S, ) -> Result<(), ProtocolContractViolation>
Appends canonical fields to a statically dispatched destination.
§Errors
Returns a typed validation, range, or destination representation error.
Sourcefn decode_from_map(map: &HeaderMap) -> Result<Self, ProtocolContractViolation>
fn decode_from_map(map: &HeaderMap) -> Result<Self, ProtocolContractViolation>
Decodes this header from borrowed extension fields.
§Errors
Returns a typed missing, conflict, conversion, range, or validation error.
Sourcefn contains_any_field(map: &HeaderMap) -> bool
fn contains_any_field(map: &HeaderMap) -> bool
Returns whether this header or any flattened child owns a present key.
Sourcefn encoded_len_hint(&self) -> usize
fn encoded_len_hint(&self) -> usize
Estimates the encoded ROCKETMQ extension-field payload length.
The result saturates at usize::MAX. It is a capacity hint and does
not validate the header or guarantee that a specific format can encode it.
Sourcefn visit_field_specs(visitor: &mut dyn FnMut(&HeaderFieldSpec))
fn visit_field_specs(visitor: &mut dyn FnMut(&HeaderFieldSpec))
Visits field schemas declared here and recursively by flattened headers.
Sourcefn visit_flatten_specs(visitor: &mut dyn FnMut(&HeaderFlattenSpec))
fn visit_flatten_specs(visitor: &mut dyn FnMut(&HeaderFlattenSpec))
Visits flatten schemas declared here and recursively by flattened headers.
Sourcefn resolve_wire_key(key: &str) -> Option<ResolvedHeaderKey>
fn resolve_wire_key(key: &str) -> Option<ResolvedHeaderKey>
Resolves a canonical key or alias to its owning typed field.
Provided Methods§
Sourcefn decode_from_source(
source: &dyn HeaderFieldSource,
) -> Result<Self, ProtocolContractViolation>
fn decode_from_source( source: &dyn HeaderFieldSource, ) -> Result<Self, ProtocolContractViolation>
Decodes this header directly from a borrowed field source.
Generated request-header codecs override this method with a zero-materialization scan. The default keeps manually implemented codecs source-compatible.
§Errors
Returns the same classified failures as Self::decode_from_map.
Sourcefn contains_any_field_source(source: &dyn HeaderFieldSource) -> bool
fn contains_any_field_source(source: &dyn HeaderFieldSource) -> bool
Returns whether this header or a flattened child owns a source field.
Sourcefn canonical_wire_key(key: &str) -> Option<&'static str>
fn canonical_wire_key(key: &str) -> Option<&'static str>
Resolves a key and returns its canonical wire key.
Sourcefn contains_wire_key(key: &str) -> bool
fn contains_wire_key(key: &str) -> bool
Returns whether a canonical key or alias belongs to this schema.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".