Struct unicode_converter::cesu_8::Cesu8
source · 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
impl UnicodeEncoding for Cesu8
source§fn from_utf_32(data_utf32: &Utf32) -> Self
fn from_utf_32(data_utf32: &Utf32) -> Self
Convert UTF-32 data to CESU-8.
source§fn to_bytes(&self, big_endian: bool) -> Vec<u8>
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>
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
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,
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
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
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
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,
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,
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.
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more