pub enum Utf8ByteType {
Continuation,
Single,
Double,
Triple,
Quadruple,
}
Expand description
Categorization of a valid byte in UTF-8
§Example
use utf8_parser::Utf8ByteType;
assert_eq!(Utf8ByteType::of(0b00000010)?, Utf8ByteType::Single);
assert_eq!(Utf8ByteType::of(0b10000010)?, Utf8ByteType::Continuation);
assert_eq!(Utf8ByteType::of(0b11000010)?, Utf8ByteType::Double);
assert_eq!(Utf8ByteType::of(0b11100010)?, Utf8ByteType::Triple);
assert_eq!(Utf8ByteType::of(0b11110010)?, Utf8ByteType::Quadruple);
assert!(Utf8ByteType::of(0b11111010).is_err());
Variants§
Continuation
A continuation byte
Single
A one-byte UTF-8 character, i.e. an ASCII value
Double
A start byte that must be followed by one continuation byte
Triple
A start byte that must be followed by two continuation bytes
Quadruple
A start byte that must be followed by three continuation bytes
Implementations§
Source§impl Utf8ByteType
impl Utf8ByteType
Sourcepub const fn of(byte: u8) -> Result<Self, Utf8ParserError>
pub const fn of(byte: u8) -> Result<Self, Utf8ParserError>
Get type of byte
Sourcepub const fn is_continuation(self) -> bool
pub const fn is_continuation(self) -> bool
Returns true if this is a continuation byte
Trait Implementations§
Source§impl Clone for Utf8ByteType
impl Clone for Utf8ByteType
Source§fn clone(&self) -> Utf8ByteType
fn clone(&self) -> Utf8ByteType
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for Utf8ByteType
impl Debug for Utf8ByteType
Source§impl Hash for Utf8ByteType
impl Hash for Utf8ByteType
Source§impl PartialEq for Utf8ByteType
impl PartialEq for Utf8ByteType
impl Copy for Utf8ByteType
impl Eq for Utf8ByteType
impl StructuralPartialEq for Utf8ByteType
Auto Trait Implementations§
impl Freeze for Utf8ByteType
impl RefUnwindSafe for Utf8ByteType
impl Send for Utf8ByteType
impl Sync for Utf8ByteType
impl Unpin for Utf8ByteType
impl UnwindSafe for Utf8ByteType
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