Struct winrt::FastHString

source ·
pub struct FastHString(_);
Expand description

A string type that should be used to create strings that can be passed to Windows Runtime functions. Creating a new FastHString is faster than creating an instance of HString because it eliminates an additional allocation. Furthermore, obtaining a HStringArg from a FastHString is basically free, which is not the case for HString.

Implementations§

Creates a new FastHString from a Rust string. FastHString uses the Rust allocator to create a storage buffer for its contents, where the string is stored in UTF-16 encoding. The buffer is freed on when the FastHString is dropped.

Examples

Basic usage:

use winrt::FastHString;
let s = FastHString::new("hello");
assert_eq!("hello", s.to_string());

Creates an empty FastHString.

Returns the length of the string in Unicode characters, as specified by WindowsGetStringLen.

Examples

Basic usage:

use winrt::FastHString;
let s = FastHString::new("hello");
assert_eq!(5, s.len());

Checks whether the string is empty.

Examples

Basic usage:

use winrt::FastHString;
let s = FastHString::empty();
assert!(s.is_empty());

Creates an HStringReference that points to the contents of this FastHString.

Examples

Basic usage:

use winrt::FastHString;
let s = FastHString::new("hello");
let r = s.make_reference();  
assert_eq!("hello", r.to_string());

Methods from Deref<Target = HStringArg>§

Trait Implementations§

The resulting type after dereferencing.
Dereferences the value.
Formats the value using the given formatter. Read more
Executes the destructor for this type. Read more
Converts to this type from the input type.
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Converts the given value to a String. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.