pub trait HeaderValue: Sealed + Sized {
const KIND: HeaderValueKind;
const ALWAYS_FITS_WIRE_LENGTH: bool = false;
// Required methods
fn to_map_value(&self) -> CheetahString;
fn encoded_len(&self) -> usize;
fn write_ascii(&self, out: &mut BytesMut);
fn decode(
raw: &str,
context: HeaderFieldContext,
) -> Result<Self, ProtocolContractViolation>;
// Provided method
fn write_json_string(&self, out: &mut BytesMut) { ... }
}Expand description
A protocol-approved request-header wire value.
Implementations must keep encoded_len and write_ascii byte-for-byte
consistent. This trait is sealed: new wire types require an explicit
implementation and compatibility review in rocketmq-protocol.
Required Associated Constants§
Sourceconst KIND: HeaderValueKind
const KIND: HeaderValueKind
Static value category used by generated schemas and diagnostics.
Provided Associated Constants§
Sourceconst ALWAYS_FITS_WIRE_LENGTH: bool = false
const ALWAYS_FITS_WIRE_LENGTH: bool = false
Whether every value of this type fits Java’s signed 32-bit wire length.
Required Methods§
Sourcefn to_map_value(&self) -> CheetahString
fn to_map_value(&self) -> CheetahString
Produces the owned value required by a crate::HeaderMap.
Sourcefn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Returns the exact number of bytes written by Self::write_ascii.
Sourcefn write_ascii(&self, out: &mut BytesMut)
fn write_ascii(&self, out: &mut BytesMut)
Appends the canonical UTF-8/ASCII wire representation without a
temporary String for scalar values.
Sourcefn decode(
raw: &str,
context: HeaderFieldContext,
) -> Result<Self, ProtocolContractViolation>
fn decode( raw: &str, context: HeaderFieldContext, ) -> Result<Self, ProtocolContractViolation>
Decodes a complete map value according to the field context.
§Errors
Returns ProtocolContractViolation::InvalidValue for malformed or overflowing
scalar values, or ProtocolContractViolation::JavaRange when an unsigned value
exceeds its field’s declared signed Java range. Errors never retain
raw.
Provided Methods§
Sourcefn write_json_string(&self, out: &mut BytesMut)
fn write_json_string(&self, out: &mut BytesMut)
Appends the canonical extension-field value as a JSON string.
Scalar implementations use their allocation-free ASCII form. Text implementations override this method to apply JSON escaping.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".