pub struct Cesu8 {
    pub data: Utf8,
}
Expand description

A wrapper for CESU-8 encoded bytes

Fields§

§data: Utf8

As CESU-8 is made of UTF-8 data, it makes sense to reuse the UTF-8 type here.

Trait Implementations§

source§

impl UnicodeEncoding for Cesu8

source§

fn from_utf_32(data_utf32: &Utf32) -> Self

Convert UTF-32 data to CESU-8.

source§

fn to_utf_32(&self) -> Utf32

Convert CESU-8 to UTF-32.

source§

fn to_bytes(&self, big_endian: bool) -> Vec<u8>

Convert the instance of Cesu8 to a vector of bytes, all the heavy lifting in made in the UTF-8 module.

source§

fn from_bytes_no_check( bytes: &[u8], big_endian: bool ) -> Result<Self, UnicodeEncodingError>

Convert a stream of bytes encoded as CESU-8 into an instance of the Cesu8 type. All the heavy lifting in made in the UTF-8 module.

source§

fn to_string(&self) -> String

Converts an Unicode encoded content and converts it to Rust’s string.
source§

fn from_string(s: &str) -> Result<Self, UnicodeEncodingError>where Self: Sized,

Takes a Rust string and converts it into Unicode encoded content.
source§

fn convert_to<T: UnicodeEncoding>(&self) -> T

Converts from one Unicode encoding to an other.
source§

fn content_eq<T: UnicodeEncoding>(&self, other: &T) -> bool

Tell if the encoded content is equal to an other encoded content, regardless of the chosen encoding.
source§

fn check_sanity(&self) -> UnicodeEncodingError

Checks that the unicode data is valid.
source§

fn from_bytes( bytes: &[u8], big_endian: bool ) -> Result<Self, UnicodeEncodingError>where Self: Sized,

The function from_bytes takes a stream of bytes and interpret it as it was in the desired encoding. It should always be implemented by the encoding’s type.
source§

fn from_file( filename: &str, big_endian: bool ) -> Result<Result<Self, UnicodeEncodingError>, Error>where Self: Sized,

Reads a file containing data encoded in an Unicode. If the file can’t be opened, an io error is returned. If the file can be open but the data is not valid, an UnicodeEncodingError will be returned. If everything goes well, the data is returned.
source§

fn to_file(data: &Self, filename: &str, big_endian: bool) -> Option<Error>

Writes Unicode data to a file. If that can be done, None is returned. If there is an IO error, the IO error is returned in the Some.

Auto Trait Implementations§

§

impl RefUnwindSafe for Cesu8

§

impl Send for Cesu8

§

impl Sync for Cesu8

§

impl Unpin for Cesu8

§

impl UnwindSafe for Cesu8

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