Skip to main content

ByteOrderGuess

Enum ByteOrderGuess 

Source
pub enum ByteOrderGuess {
    Utf8,
    Utf16Le,
    Utf16Be,
    Utf32Le,
    Utf32Be,
    Utf32Order2143,
    Utf32Order3412,
    Ebcdic,
}
Expand description

The coarse encoding family implied purely by the first few bytes of an XML entity, before any attempt to read an encoding="..." declaration.

This mirrors the byte-pattern table of XML 1.0 Appendix F.1 in full, including the UTF-32 and EBCDIC patterns that this crate cannot itself decode (Encoding has no such variants) — recognizing the pattern is still useful so a caller can produce a precise diagnostic (“this looks like EBCDIC, which is unsupported”) instead of a generic decode failure. Use ByteOrderGuess::supported_encoding to get the Encoding this crate can actually decode with, if any.

Variants§

§

Utf8

EF BB BF (BOM) or 3C 3F 78 6D (<?xm as ASCII/UTF-8/Latin-1/windows-1252/…).

§

Utf16Le

FF FE (BOM) or 3C 00 3F 00 (<?xm as UTF-16, little-endian, no BOM).

§

Utf16Be

FE FF (BOM) or 00 3C 00 3F (<?xm as UTF-16, big-endian, no BOM).

§

Utf32Le

FF FE 00 00: UTF-32, little-endian. Not decodable by this crate.

§

Utf32Be

00 00 FE FF: UTF-32, big-endian. Not decodable by this crate.

§

Utf32Order2143

00 00 FF FE: UTF-32 with an unusual 2-1-4-3 octet order. Not decodable by this crate.

§

Utf32Order3412

FE FF 00 00: UTF-32 with an unusual 3-4-1-2 octet order. Not decodable by this crate.

§

Ebcdic

4C 6F A7 94 (<?xm in an EBCDIC code page). Not decodable by this crate.

Implementations§

Source§

impl ByteOrderGuess

Source

pub const fn supported_encoding(self) -> Option<Encoding>

The Encoding this crate can actually decode with for this guess, if any.

ByteOrderGuess::Utf8 maps to Encoding::Utf8 here as a transport guess only: at this stage all that’s known is that the entity is ASCII-compatible, not specifically that it is UTF-8 rather than, say, windows-1252 — SniffResult::declared_encoding (read from the prologue) is what actually distinguishes those.

Trait Implementations§

Source§

impl Clone for ByteOrderGuess

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ByteOrderGuess

Source§

impl Debug for ByteOrderGuess

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ByteOrderGuess

Source§

impl PartialEq for ByteOrderGuess

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ByteOrderGuess

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.