#[repr(transparent)]
pub struct NtUnicodeStrMut<'a> { /* private fields */ }
Expand description

A mutable reference to a UNICODE_STRING (equivalent of &mut str).

See the module-level documentation for more details.

Implementations§

source§

impl<'a> NtUnicodeStrMut<'a>

source

pub fn as_mut_ptr(&mut self) -> *mut Self

Returns a *mut NtUnicodeStrMut pointer (mainly for non-Rust interfaces that expect a mutable UNICODE_STRING*).

source

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

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

source

pub fn as_mut_u16str(&mut self) -> &'a U16Str

Returns a mutable U16Str reference for this string.

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

source

pub fn as_unicode_str(&'a self) -> &NtUnicodeStr<'a>

Returns an immutable NtUnicodeStr reference for this string.

source

pub fn clear(&mut self)

Truncates this string, removing all contents.

While this means the string will have a length of zero, it does not touch its capacity.

source

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

Creates an NtUnicodeStrMut 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 pop(&mut self) -> Option<Result<char>>

Removes the last character from the string and returns it.

An NtStringError::UnpairedUtf16Surrogate error is returned if the last character is an unpaired surrogate. In that case, the unpaired surrogate codepoint is removed from the string anyway.

None is returned if this string is empty.

source

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

Creates an NtUnicodeStrMut 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 NtUnicodeStrMut 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: &mut [u16]) -> Result<Self>

Creates an NtUnicodeStrMut 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 NtUnicodeStrMut 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.

Methods from Deref<Target = 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 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.

Trait Implementations§

source§

impl<'a> Debug for NtUnicodeStrMut<'a>

source§

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

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

impl<'a> Deref for NtUnicodeStrMut<'a>

§

type Target = NtUnicodeStr<'a>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<'a> Display for NtUnicodeStrMut<'a>

source§

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

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

impl<'a> Ord for NtUnicodeStrMut<'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) -> Selfwhere Self: Sized,

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

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

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

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

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

impl<'a, 'b> PartialEq<&str> for NtUnicodeStrMut<'a>

source§

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

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

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

This method 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

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

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

This method 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 &str

source§

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

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

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

This method 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

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

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

This method 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 NtUnicodeStrMut<'b>

source§

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

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

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

This method 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 NtUnicodeString

source§

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

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

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

This method 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 str

source§

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

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

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

This method 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 NtUnicodeStrMut<'a>

source§

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

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

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

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

impl<'a, 'b> PartialEq<str> for NtUnicodeStrMut<'a>

source§

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

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

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

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

impl<'a, 'b> PartialOrd<&str> for NtUnicodeStrMut<'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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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 &str

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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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 NtUnicodeStrMut<'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

This method 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

This method 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

This method 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

This method 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 NtUnicodeString

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

This method 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

This method 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

This method 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

This method 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 str

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

This method 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

This method 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

This method 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

This method 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 NtUnicodeStrMut<'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

This method 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

This method 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

This method 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

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

impl<'a, 'b> PartialOrd<str> for NtUnicodeStrMut<'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

This method 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

This method 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

This method 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

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

impl<'a> TryFrom<&'a mut U16CStr> for NtUnicodeStrMut<'a>

source§

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

Converts a mutable U16CStr reference into an NtUnicodeStrMut.

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

§

type Error = NtStringError

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

impl<'a> TryFrom<&'a mut U16Str> for NtUnicodeStrMut<'a>

source§

fn try_from(value: &'a mut 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.

§

type Error = NtStringError

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

impl<'a> Eq for NtUnicodeStrMut<'a>

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for NtUnicodeStrMut<'a>

§

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

§

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

§

impl<'a> Unpin for NtUnicodeStrMut<'a>

§

impl<'a> UnwindSafe for NtUnicodeStrMut<'a>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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> ToString for Twhere 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 Twhere U: Into<T>,

§

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

§

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.