Struct NtUnicodeStr

Source
pub struct NtUnicodeStr<'a> { /* private fields */ }
Expand description

An immutable reference to a UNICODE_STRING (equivalent of &str).

See the module-level documentation for more details.

Implementations§

Source§

impl<'a> NtUnicodeStr<'a>

Source

pub fn as_ptr(&self) -> *const Self

Returns a *const NtUnicodeStr pointer (mainly for non-Rust interfaces that expect an immutable UNICODE_STRING*).

Source

pub fn as_slice(&self) -> &'a [u16]

Returns a slice to the raw u16 codepoints of the string.

Source

pub fn as_u16str(&self) -> &'a U16Str

Returns a U16Str reference for this string.

The U16Str will only contain the characters and not the NUL terminator.

Source

pub fn capacity(&self) -> u16

Returns the capacity (also known as “maximum length”) of this string, in bytes.

Source

pub fn chars(&self) -> Chars<'_>

Returns an iterator over the chars of this string.

As the string may contain invalid UTF-16 characters (unpaired surrogates), the returned iterator is an iterator over Result<char>. Unpaired surrogates are returned as an NtStringError::UnpairedUtf16Surrogate error. If you would like a lossy iterator over chars directly, use chars_lossy instead.

Source

pub fn chars_lossy(&self) -> CharsLossy<'_>

Returns an iterator over the chars of this string.

Any invalid UTF-16 characters (unpaired surrogates) are automatically replaced by U+FFFD REPLACEMENT CHARACTER (�). If you would like to treat them differently, use chars instead.

Source

pub const unsafe fn from_raw_parts( buffer: *const u16, length: u16, maximum_length: u16, ) -> Self

Creates an NtUnicodeStr from a u16 string buffer, a byte length of the string, and a buffer capacity in bytes (also known as “maximum length”).

The string is expected to consist of valid UTF-16 characters. The buffer may or may not be NUL-terminated. In any case, length does NOT include the terminating NUL character.

This function is unsafe and you are advised to use any of the safe try_from_* functions over this one if possible.

§Safety

Behavior is undefined if any of the following conditions are violated:

  • length must be less than or equal to maximum_length.
  • buffer must be valid for at least maximum_length bytes.
  • buffer must point to length consecutive properly initialized bytes.
  • buffer must be valid for the duration of lifetime 'a.
Source

pub fn is_empty(&self) -> bool

Returns true if this string has a length of zero, and false otherwise.

Source

pub fn len(&self) -> u16

Returns the length of this string, in bytes.

Note that a single character may occupy more than one byte. In other words, the returned value might not be what a human considers the length of the string.

Source

pub fn try_from_u16(buffer: &'a [u16]) -> Result<Self>

Creates an NtUnicodeStr from an existing u16 string buffer without a terminating NUL character.

The string is expected to consist of valid UTF-16 characters.

The given buffer becomes the internal buffer of the NtUnicodeStr and therefore won’t be NUL-terminated. See the module-level documentation for the implications of that.

This function has O(1) complexity.

If you have a NUL-terminated buffer, either use try_from_u16_until_nul or convert from a U16CStr using the corresponding TryFrom implementation.

Source

pub fn try_from_u16_until_nul(buffer: &'a [u16]) -> Result<Self>

Creates an NtUnicodeStr from an existing u16 string buffer that contains at least one NUL character.

The string is expected to consist of valid UTF-16 characters.

The string will be terminated at the NUL character. An NtStringError::NulNotFound error is returned if no NUL character could be found. As a consequence, this function has O(n) complexity.

The resulting internal buffer of NtUnicodeStr will be NUL-terminated. See the module-level documentation for the implications of that.

Use try_from_u16 if you have a buffer that is not NUL-terminated. You can also convert from a NUL-terminated U16CStr in O(1) via the corresponding TryFrom implementation.

Trait Implementations§

Source§

impl<'a> Clone for NtUnicodeStr<'a>

Source§

fn clone(&self) -> NtUnicodeStr<'a>

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<'a> Debug for NtUnicodeStr<'a>

Source§

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

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

impl<'a> Display for NtUnicodeStr<'a>

Source§

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

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

impl<'a> From<&NtUnicodeStr<'a>> for NtUnicodeString

Source§

fn from(unicode_str: &NtUnicodeStr<'_>) -> Self

Creates an NtUnicodeString from an existing NtUnicodeStr.

This implementation keeps the original capacity.

Source§

impl<'a> Ord for NtUnicodeStr<'a>

Source§

fn cmp(&self, other: &Self) -> 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,

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

impl<'a> PartialEq<&str> for NtUnicodeStr<'a>

Source§

fn eq(&self, other: &&str) -> 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<'a> PartialEq<NtUnicodeStr<'a>> for &str

Source§

fn eq(&self, other: &NtUnicodeStr<'a>) -> 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<'a, 'b> PartialEq<NtUnicodeStr<'a>> for NtUnicodeStr<'b>

Source§

fn eq(&self, other: &NtUnicodeStr<'a>) -> bool

Checks that two strings are a (case-sensitive!) match.

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<'a, 'b> PartialEq<NtUnicodeStr<'a>> for NtUnicodeStrMut<'b>

Source§

fn eq(&self, other: &NtUnicodeStr<'a>) -> 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<'a, 'b> PartialEq<NtUnicodeStr<'a>> for NtUnicodeString

Source§

fn eq(&self, other: &NtUnicodeStr<'a>) -> 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<'a> PartialEq<NtUnicodeStr<'a>> for str

Source§

fn eq(&self, other: &NtUnicodeStr<'a>) -> 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<'a, 'b> PartialEq<NtUnicodeStrMut<'a>> for NtUnicodeStr<'b>

Source§

fn eq(&self, other: &NtUnicodeStrMut<'a>) -> 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<'a, 'b> PartialEq<NtUnicodeString> for NtUnicodeStr<'a>

Source§

fn eq(&self, other: &NtUnicodeString) -> 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<'a> PartialEq<str> for NtUnicodeStr<'a>

Source§

fn eq(&self, other: &str) -> 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<'a> PartialOrd<&str> for NtUnicodeStr<'a>

Source§

fn partial_cmp(&self, other: &&str) -> 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<'a> PartialOrd<NtUnicodeStr<'a>> for &str

Source§

fn partial_cmp(&self, other: &NtUnicodeStr<'a>) -> 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<'a, 'b> PartialOrd<NtUnicodeStr<'a>> for NtUnicodeStrMut<'b>

Source§

fn partial_cmp(&self, other: &NtUnicodeStr<'a>) -> 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<'a, 'b> PartialOrd<NtUnicodeStr<'a>> for NtUnicodeString

Source§

fn partial_cmp(&self, other: &NtUnicodeStr<'a>) -> 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<'a> PartialOrd<NtUnicodeStr<'a>> for str

Source§

fn partial_cmp(&self, other: &NtUnicodeStr<'a>) -> 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<'a, 'b> PartialOrd<NtUnicodeStrMut<'a>> for NtUnicodeStr<'b>

Source§

fn partial_cmp(&self, other: &NtUnicodeStrMut<'a>) -> 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<'a, 'b> PartialOrd<NtUnicodeString> for NtUnicodeStr<'a>

Source§

fn partial_cmp(&self, other: &NtUnicodeString) -> 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<'a> PartialOrd<str> for NtUnicodeStr<'a>

Source§

fn partial_cmp(&self, other: &str) -> 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<'a> PartialOrd for NtUnicodeStr<'a>

Source§

fn partial_cmp(&self, other: &Self) -> 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<'a> TryFrom<&'a U16CStr> for NtUnicodeStr<'a>

Source§

fn try_from(value: &'a U16CStr) -> Result<Self>

Converts a U16CStr reference into an NtUnicodeStr.

The internal buffer will be NUL-terminated. See the module-level documentation for the implications of that.

Source§

type Error = NtStringError

The type returned in the event of a conversion error.
Source§

impl<'a> TryFrom<&'a U16Str> for NtUnicodeStr<'a>

Source§

fn try_from(value: &'a U16Str) -> Result<Self>

Converts a U16Str reference into an NtUnicodeStr.

The internal buffer will NOT be NUL-terminated. See the module-level documentation for the implications of that.

Source§

type Error = NtStringError

The type returned in the event of a conversion error.
Source§

impl<'a> Copy for NtUnicodeStr<'a>

Source§

impl<'a> Eq for NtUnicodeStr<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for NtUnicodeStr<'a>

§

impl<'a> RefUnwindSafe for NtUnicodeStr<'a>

§

impl<'a> !Send for NtUnicodeStr<'a>

§

impl<'a> !Sync for NtUnicodeStr<'a>

§

impl<'a> Unpin for NtUnicodeStr<'a>

§

impl<'a> UnwindSafe for NtUnicodeStr<'a>

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> 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§

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.