Struct intercom::BStr
[−]
[src]
#[repr(C)]pub struct BStr(_);
A Rust wrapper for the BSTR
string type.
Used for passing Rust String
types through the COM interfaces. Intercom
should take care of the conversion in most cases, allowing the user to
stick with String
types in their own code.
BSTR
details
The BSTR
is both a length prefixed and zero terminated string with UTF-16
encoding. It is the string type widely used with Microsoft COM for
interoperability purposes.
What makes the BSTR
exotic is that the *mut u16
pointer references the
start of the string data. The length prefix is located before the pointed
value.
It is important to note that when COM servers return BSTR
strings, they
pass ownership of the string to the COM client. After this the COM client
is responsible for de-allocating the memory. Because of this it is
important that the memory allocation for BSTR
values is well defined.
On Windows this means allocating the strings using SysAllocString
or
SysAllocStringLen
methods and freeing them with SysFreeString
by
default.
Methods
impl BStr
[src]
pub fn len_bytes(&self) -> u32
[src]
Returns the text length in bytes.
Does not include the length prefix or the terminating zero. However any zero bytes in the middle of the string are included.
pub fn string_to_bstr(s: &str) -> BStr
[src]
Converts a Rust string into a BStr
.
pub fn bstr_to_string(&self) -> String
[src]
Converts a BStr
into a Rust String
.