Struct BStr

Source
pub struct BStr(/* private fields */);
Expand description

Represents a borrowed BSTR string.

Implementations§

Source§

impl BStr

Source

pub unsafe fn from_ptr<'a>(ptr: *const u16) -> &'a BStr

Unsafely creates a BStr from a BSTR pointer.

This function will cast the pointer into a BStr. The provied pointer must be a valid BSTR pointer and must be valid while the BStr is alive. The BStr must also not be moved.

§Safety

The parameter must be a valid BSTR pointer. This includes both the memory layout and allocation using BSTR-compatible allocation functions.

In addition to this the pointer must be kept alive while the returned reference is in use.

Source

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

Returns the pointer as a 16-bit wide character pointer.

Source

pub fn len_bytes(&self) -> u32

Returns the string 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.

Source

pub fn len(&self) -> u32

Returns the string length in characters.

Source

pub fn is_empty(&self) -> bool

Source

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

Gets the BStr as a slice of 16-bit characters.

Source

pub fn to_string(&self) -> Result<String, FormatError>

Trait Implementations§

Source§

impl AsRef<BStr> for BStr

Source§

fn as_ref(&self) -> &BStr

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<BStr> for BString

Source§

fn as_ref(&self) -> &BStr

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<BStr> for BString

Source§

fn borrow(&self) -> &BStr

Immutably borrows from an owned value. Read more
Source§

impl Debug for BStr

Source§

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

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

impl<'a> ExternInput<AutomationTypeSystem> for &'a BStr

Source§

type Lease = ()

Source§

type Owned = &'a BStr

Source§

unsafe fn into_foreign_parameter( self, ) -> ComResult<(Self::ForeignType, Self::Lease)>

Safety Read more
Source§

unsafe fn from_foreign_parameter( source: Self::ForeignType, ) -> ComResult<Self::Owned>

Safety Read more
Source§

impl<'a> ExternInput<RawTypeSystem> for &'a BStr

Source§

type Lease = CString

Source§

type Owned = BString

Source§

unsafe fn into_foreign_parameter( self, ) -> ComResult<(Self::ForeignType, Self::Lease)>

Safety Read more
Source§

unsafe fn from_foreign_parameter( source: Self::ForeignType, ) -> ComResult<Self::Owned>

Safety Read more
Source§

impl<'a> ExternType<AutomationTypeSystem> for &'a BStr

Source§

impl<'a> ExternType<RawTypeSystem> for &'a BStr

Source§

impl PartialEq for BStr

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl ToOwned for BStr

Source§

type Owned = BString

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> Self::Owned

Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · Source§

fn clone_into(&self, target: &mut Self::Owned)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl Eq for BStr

Source§

impl StructuralPartialEq for BStr

Auto Trait Implementations§

§

impl Freeze for BStr

§

impl RefUnwindSafe for BStr

§

impl Send for BStr

§

impl !Sized 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