Skip to main content

CharsetCodec

Trait CharsetCodec 

Source
pub trait CharsetCodec: Codec<Value = char, DecodeError = CharsetDecodeError, EncodeError = CharsetEncodeError> {
    // Required method
    fn charset(&self) -> Charset;
}
Expand description

Charset metadata carried by a low-level Codec<Value = char>.

CharsetCodec stays at the same low-level layer as Codec. It identifies the charset, while actual storage unit type, single-value encoding, and decoding are provided by the inherited unsafe Codec contract. Checked buffer management, stream boundary handling, replacement policy, and unmappable-character policy live in crate::CharsetDecoder and crate::CharsetEncoder.

Built-in variable-width codecs report incomplete prefixes through CharsetDecodeError, so buffered decoders can call Codec::decode_unchecked as soon as at least Codec::min_units_per_value units are available.

§Associated Types

Implementors must also implement the low-level Codec contract with Value = char, plus CharsetDecodeError and CharsetEncodeError as the concrete error types. The storage unit is inherited from Codec::Unit, keeping text wrappers bound to the same object without duplicating associated types.

Required Methods§

Source

fn charset(&self) -> Charset

Returns the charset handled by this codec.

§Returns

Returns the codec’s charset descriptor.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§