Struct winsafe::BSTR

source ·
pub struct BSTR(/* private fields */);
Available on crate feature oleaut only.
Expand description

A string data type used with COM automation.

Automatically calls SysFreeString when the object goes out of scope.

Implementations§

source§

impl BSTR

source

pub fn SysAllocString(s: &str) -> HrResult<Self>

SysAllocString function.

source

pub fn SysReAllocString(&mut self, s: &str) -> HrResult<()>

SysReAllocString function.

The underlying pointer is automatically updated.

source

pub fn SysStringLen(&self) -> u32

SysStringLen function.

source

pub const unsafe fn from_ptr(p: *mut u16) -> Self

Creates a new BSTR by wrapping a pointer.

§Safety

Be sure the pointer has the correct type and isn’t owned by anyone else, otherwise you may cause memory access violations.

source

pub const fn as_ptr(&self) -> *mut u16

Returns the underlying LPWSTR pointer to the null-terminated wide string.

source

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

Returns the underlying LPWSTR memory block as a null-terminated u16 slice.

source

pub fn leak(&mut self) -> *mut u16

Ejects the underlying LPWSTR pointer leaving a null pointer in its place, so that SysFreeString won’t be called.

Be sure to free the pointer, otherwise, as the name of this method implies, you will cause a memory leak.

Trait Implementations§

source§

impl Debug for BSTR

source§

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

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

impl Default for BSTR

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Display for BSTR

source§

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

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

impl Drop for BSTR

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl From<BSTR> for WString

source§

fn from(v: BSTR) -> WString

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for BSTR

§

impl RefUnwindSafe for BSTR

§

impl !Send for BSTR

§

impl !Sync for BSTR

§

impl Unpin for BSTR

§

impl UnwindSafe for BSTR

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> 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> ToString for T
where 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 T
where 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 T
where 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.