Enum unicode_bom::Bom

source ·
pub enum Bom {
    Null,
    Bocu1,
    Gb18030,
    Scsu,
    UtfEbcdic,
    Utf1,
    Utf7,
    Utf8,
    Utf16Be,
    Utf16Le,
    Utf32Be,
    Utf32Le,
}
Expand description

Unicode byte-order mark (BOM) abstraction.

Variants§

§

Null

Indicates no BOM was detected.

§

Bocu1

Indicates BOCU-1 BOM was detected.

§

Gb18030

Indicates GB 18030 BOM was detected.

§

Scsu

Indicates SCSU BOM was detected.

§

UtfEbcdic

Indicates UTF-EBCIDC BOM was detected.

§

Utf1

Indicates UTF-1 BOM was detected.

§

Utf7

Indicates UTF-7 BOM was detected.

§

Utf8

Indicates UTF-8 BOM was detected.

§

Utf16Be

Indicates UTF-16 (big-endian) BOM was detected.

§

Utf16Le

Indicates UTF-16 (little-endian) BOM was detected.

§

Utf32Be

Indicates UTF-32 (big-endian) BOM was detected.

§

Utf32Le

Indicates UTF-32 (little-endian) BOM was detected.

Implementations§

source§

impl Bom

source

pub fn len(&self) -> usize

Returns the size in bytes of the BOM.

Trait Implementations§

source§

impl AsRef<[u8]> for Bom

source§

fn as_ref(&self) -> &[u8]

Returns the BOM byte-array literal.

Note that for UTF-7, only the first three bytes of the BOM are returned. That’s because the last two bits of the fourth byte belong to the following character, so it’s impossible to return the fourth byte without further context. Possible values for the missing fourth byte are 0x38, 0x39, 0x2a and 0x2b.

source§

impl AsRef<str> for Bom

source§

fn as_ref(&self) -> &str

Returns a &str representation of the BOM type.

source§

impl Clone for Bom

source§

fn clone(&self) -> Bom

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Bom

source§

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

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

impl Default for Bom

source§

fn default() -> Self

Returns the default/empty BOM type, Bom::Null.

source§

impl Display for Bom

source§

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

Formats the BOM type as a String.

source§

impl From<&[u8]> for Bom

source§

fn from(slice: &[u8]) -> Self

Detect the BOM type from a byte array.

source§

impl From<&mut File> for Bom

source§

fn from(file: &mut File) -> Self

Detect the BOM type from a File instance.

Note that I/O errors are swallowed by this method. Instead the default type, Bom::Null, will be returned.

source§

impl FromStr for Bom

§

type Err = Error

A std::io::Error instance returned by std::fs::File::open.

source§

fn from_str(path: &str) -> Result<Self, Self::Err>

Parse the BOM type from the file located at path.

source§

impl PartialEq for Bom

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Bom

source§

impl Eq for Bom

source§

impl StructuralPartialEq for Bom

Auto Trait Implementations§

§

impl RefUnwindSafe for Bom

§

impl Send for Bom

§

impl Sync for Bom

§

impl Unpin for Bom

§

impl UnwindSafe for Bom

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.