Struct CharULE

struct CharULE(_)

A u8 array of little-endian data corresponding to a Unicode scalar value.

The bytes of a CharULE are guaranteed to represent a little-endian-encoded u32 that is a valid char and can be converted without validation.

Examples

Convert a char to a CharULE and back again:

use zerovec::ule::{AsULE, CharULE, ULE};

let c1 = '𑄃';
let ule = c1.to_unaligned();
assert_eq!(CharULE::slice_as_bytes(&[ule]), &[0x03, 0x11, 0x01]);
let c2 = char::from_unaligned(ule);
assert_eq!(c1, c2);

Attempt to parse invalid bytes to a CharULE:

use zerovec::ule::{CharULE, ULE};

let bytes: &[u8] = &[0xFF, 0xFF, 0xFF, 0xFF];
CharULE::parse_bytes_to_slice(bytes).expect_err("Invalid bytes");

Implementations

impl CharULE

const fn from_aligned(c: char) -> Self

Converts a char to a CharULE. This is equivalent to calling [AsULE::to_unaligned()]

See the type-level documentation for CharULE for more information.

fn to_char(self: Self) -> char

Converts this CharULE to a char. This is equivalent to calling AsULE::from_unaligned

See the type-level documentation for CharULE for more information.

const fn from_array<N: usize>(arr: [char; N]) -> [Self; N]

Convert an array of char to an array of CharULE.

impl Clone for CharULE

fn clone(self: &Self) -> CharULE

impl Copy for CharULE

impl Debug for CharULE

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

impl Eq for CharULE

impl Freeze for CharULE

impl Hash for CharULE

fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H)

impl Ord for CharULE

fn cmp(self: &Self, other: &Self) -> Ordering

impl PartialEq for CharULE

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

impl PartialOrd for CharULE

fn partial_cmp(self: &Self, other: &Self) -> Option<Ordering>

impl RefUnwindSafe for CharULE

impl Send for CharULE

impl StructuralPartialEq for CharULE

impl Sync for CharULE

impl ULE for CharULE

fn validate_bytes(bytes: &[u8]) -> Result<(), UleError>

impl Unpin for CharULE

impl UnsafeUnpin for CharULE

impl UnwindSafe for CharULE

impl<T> Any for CharULE

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for CharULE

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for CharULE

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

impl<T> CloneToUninit for CharULE

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

impl<T> ErasedDestructor for CharULE

impl<T> From for CharULE

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for CharULE

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T, U> Into for CharULE

fn into(self: Self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom for CharULE

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

impl<T, U> TryInto for CharULE

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