Skip to main content

HeaderValue

Trait HeaderValue 

Source
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§

Source

const KIND: HeaderValueKind

Static value category used by generated schemas and diagnostics.

Provided Associated Constants§

Source

const ALWAYS_FITS_WIRE_LENGTH: bool = false

Whether every value of this type fits Java’s signed 32-bit wire length.

Required Methods§

Source

fn to_map_value(&self) -> CheetahString

Produces the owned value required by a crate::HeaderMap.

Source

fn encoded_len(&self) -> usize

Returns the exact number of bytes written by Self::write_ascii.

Source

fn write_ascii(&self, out: &mut BytesMut)

Appends the canonical UTF-8/ASCII wire representation without a temporary String for scalar values.

Source

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§

Source

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".

Implementations on Foreign Types§

Source§

impl HeaderValue for BoundaryType

Source§

const KIND: HeaderValueKind = HeaderValueKind::BoundaryType

Source§

const ALWAYS_FITS_WIRE_LENGTH: bool = true

Source§

fn to_map_value(&self) -> CheetahString

Source§

fn encoded_len(&self) -> usize

Source§

fn write_ascii(&self, out: &mut BytesMut)

Source§

fn decode( raw: &str, _context: HeaderFieldContext, ) -> Result<Self, ProtocolContractViolation>

Source§

impl HeaderValue for CheetahString

Source§

impl HeaderValue for String

Source§

impl HeaderValue for bool

Source§

impl HeaderValue for i32

Source§

impl HeaderValue for i64

Source§

impl HeaderValue for u32

Source§

impl HeaderValue for u64

Implementors§