pub trait Utf8Handler {
type Output;
// Required methods
fn single_byte(&self, ascii: Ascii) -> Self::Output;
fn two_byte(&self, sequence: TwoByteSequence) -> Self::Output;
fn three_byte(&self, sequence: ThreeByteSequence) -> Self::Output;
fn four_byte(&self, sequence: FourByteSequence) -> Self::Output;
// Provided method
fn error(&self) -> Self::Output { ... }
}Expand description
Mapping from the four kinds of byte sequences or error to output.
Required Associated Types§
Required Methods§
Sourcefn single_byte(&self, ascii: Ascii) -> Self::Output
fn single_byte(&self, ascii: Ascii) -> Self::Output
Map a single-byte UTF-8 sequence to Output.
When Output is char, ascii.to_char()
is the appropriate implementation.
The implementation is expected to be marked
#[inline(always)].
Sourcefn two_byte(&self, sequence: TwoByteSequence) -> Self::Output
fn two_byte(&self, sequence: TwoByteSequence) -> Self::Output
Map a two-byte UTF-8 sequence to Output.
When Output is char, sequence.to_char()
is the appropriate implementation.
The implementation is expected to be marked
#[inline(always)].
Sourcefn three_byte(&self, sequence: ThreeByteSequence) -> Self::Output
fn three_byte(&self, sequence: ThreeByteSequence) -> Self::Output
Map a three-byte UTF-8 sequence to Output.
When Output is char, sequence.to_char()
is the appropriate implementation.
The implementation is expected to be marked
#[inline(always)].
Sourcefn four_byte(&self, sequence: FourByteSequence) -> Self::Output
fn four_byte(&self, sequence: FourByteSequence) -> Self::Output
Map a four-byte UTF-8 sequence to Output.
When Output is char, sequence.to_char()
is the appropriate implementation.
The implementation is expected to be marked
#[inline(always)].
Provided Methods§
Sourcefn error(&self) -> Self::Output
fn error(&self) -> Self::Output
Map a single UTF-8 error to Output.
What constitutes a single error is defined by the WHATWG Encoding Standard.
When Output is char,
char::REPLACEMENT_CHARACTER
is the appropriate implementation. The provided
implementation delegates to three_byte by
passing the three bytes that represent the
REPLACEMENT CHARACTER.
The implementation of this method is expected to
be declared #[inline(always)].
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".