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]

[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.

[src]

Converts a Rust string into a BStr.

[src]

Converts a BStr into a Rust String.

Trait Implementations

impl Default for BStr
[src]

[src]

Default value representing an empty string.

impl From<BStr> for String
[src]

[src]

Performs the conversion.

impl From<String> for BStr
[src]

[src]

Performs the conversion.

Auto Trait Implementations

impl !Send for BStr

impl !Sync for BStr