Struct ucs2::Ucs2LeVec

source ·
pub struct Ucs2LeVec(/* private fields */);
Expand description

Wrapper around Vec<u8> containing a valid null-terminated UCS-2 LE string.

This type is not FFI compatible with *const u16!

Because Ucs2LeVec uses a [u8] as the backing data type (as opposed to a [u16]), the data is not guaranteed to be u16 aligned!

DEVNOTE: While we want Ucs2LeSlice to be backed by a [u8], Ucs2LeVec should likely get switched over to a Vec<u16>, so we can get proper u16 alignment. Note that in this case, we could use a bit of (trivially save) unsafe code to impl Deref<Target = Ucs2LeSlice> by reinterpretting the Vec<u16> as a &[u8], so there wouldn’t be any major ergonomic hit.

Implementations§

source§

impl Ucs2LeVec

source

pub fn from_vec_with_nul(buf: Vec<u8>) -> Result<Ucs2LeVec, Ucs2ParseError>

Validate that the provided Vec<u8> is a valid null-terminated UCS-2 LE string, truncating the slice to the position of the first null u16.

source

pub fn into_inner(self) -> Vec<u8>

Consume self, returning the underlying raw Vec<u8>

Methods from Deref<Target = Ucs2LeSlice>§

source

pub fn as_bytes(&self) -> &[u8]

View the underlying data as raw bytes.

source

pub fn as_bytes_without_nul(&self) -> &[u8]

View the underlying data as raw bytes, without the trailing null u16.

source

pub fn to_ucs2_le_vec(&self) -> Ucs2LeVec

Copies self into a new Ucs2LeVec.

Trait Implementations§

source§

impl AsRef<Ucs2LeSlice> for Ucs2LeVec

source§

fn as_ref(&self) -> &Ucs2LeSlice

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Borrow<Ucs2LeSlice> for Ucs2LeVec

source§

fn borrow(&self) -> &Ucs2LeSlice

Immutably borrows from an owned value. Read more
source§

impl Clone for Ucs2LeVec

source§

fn clone(&self) -> Ucs2LeVec

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 Ucs2LeVec

source§

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

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

impl Default for Ucs2LeVec

source§

fn default() -> Ucs2LeVec

Returns the “default value” for a type. Read more
source§

impl DefaultEncoding for Ucs2LeVec

source§

type Encoding = TableEncoder

The encoding to use for the serialization. Read more
source§

impl Deref for Ucs2LeVec

source§

type Target = Ucs2LeSlice

The resulting type after dereferencing.
source§

fn deref(&self) -> &Ucs2LeSlice

Dereferences the value.
source§

impl Display for Ucs2LeVec

source§

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

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

impl<'a> From<&'a str> for Ucs2LeVec

source§

fn from(s: &'a str) -> Ucs2LeVec

Converts to this type from the input type.
source§

impl From<String> for Ucs2LeVec

source§

fn from(s: String) -> Ucs2LeVec

Converts to this type from the input type.
source§

impl<'a> From<Ucs2LeVec> for Cow<'a, Ucs2LeSlice>

source§

fn from(val: Ucs2LeVec) -> Self

Converts to this type from the input type.
source§

impl Hash for Ucs2LeVec

source§

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

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for Ucs2LeVec

source§

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

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for Ucs2LeVec

source§

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

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

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

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

impl PartialOrd for Ucs2LeVec

source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'encoding, AnyR: 'static> StructDecodeMetadata<'encoding, AnyR> for Ucs2LeVec

source§

const DECODERS: &'static [ErasedDecoderEntry] = _

The list of decoder vtables.
source§

impl<AnyR: 'static> StructEncodeMetadata<AnyR> for Ucs2LeVec

source§

const ENCODERS: &'static [ErasedEncoderEntry] = _

The list of encoder vtables.
source§

impl StructMetadata for Ucs2LeVec

source§

const NUMBERS: &'static [u32] = _

The field numbers for each field.
source§

const OFFSETS: &'static [usize] = _

The byte offset to each field within the struct.
source§

impl Downcast<Ucs2LeVec> for Ucs2LeVec

source§

impl Eq for Ucs2LeVec

source§

impl StructuralPartialEq for Ucs2LeVec

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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 T
where 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> Protobuf for T

source§

type Encoding = <T as DefaultEncoding>::Encoding

The default encoding for Self.
source§

impl<T> ToOwned for T
where T: Clone,

source§

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 T
where 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 T
where U: Into<T>,

source§

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 T
where U: TryFrom<T>,

source§

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.
source§

impl<T, U> Upcast<U> for T
where U: Downcast<T>,