[][src]Struct winstr::BString

#[repr(transparent)]pub struct BString(_);

BString is a non-null, owned, BSTR (32-bit length prefixed UTF-16ish string).

Implementations

impl BString[src]

pub fn from_code_units(
    code_units: impl ExactSizeIterator + Iterator<Item = u16>
) -> Option<BString>
[src]

Create an owned BSTR from 0 or more u16 unicode code points.

impl BString[src]

pub fn from_str(s: impl AsRef<str>) -> Option<Self>[src]

Create a BString from a str

pub fn from_osstr(s: impl AsRef<OsStr>) -> Option<Self>[src]

Create a BString from a OsStr

pub fn from_bstr(s: impl AsRef<BStr>) -> Option<Self>[src]

Create a BString from a BStr

Methods from Deref<Target = BStr>

pub fn as_bstr(&self) -> BSTR[src]

The &BStr as a winapi-friendly BSTR.

Safety

  • s.as_bstr() is guaranteed to be 0u16-terminated
  • It is not safe to modify the contents of the BSTR through the returned pointer!

pub fn len32(&self) -> u32[src]

32-bit length in u16 unicode code units, excluding the implicit terminal 0u16

pub fn units0(&self) -> &[u16][src]

The u16 unicode code units of the string, including the terminal 0u16

pub fn as_lpcwstr(&self) -> LPCWSTR[src]

LPCWSTR / * const wchar_t

pub fn len320(&self) -> u32[src]

32-bit length in u16 unicode code units, including the implicit terminal 0u16

pub fn len(&self) -> usize[src]

Length in u16 unicode code units, excluding the implicit terminal 0u16

pub fn len0(&self) -> usize[src]

Length in u16 unicode code units, including the implicit terminal 0u16

pub fn units(&self) -> &[u16][src]

The u16 unicode code units of the string, excluding the terminal 0u16

Trait Implementations

impl AsRef<[u16]> for BString[src]

impl AsRef<BStr> for BString[src]

impl Borrow<[u16]> for BString[src]

impl Borrow<BStr> for BString[src]

impl Clone for BString[src]

impl Debug for BString[src]

impl Deref for BString[src]

type Target = BStr

The resulting type after dereferencing.

impl Display for BString[src]

impl Drop for BString[src]

impl Eq for BString[src]

impl<'_> From<&'_ BStr> for BString[src]

impl<'_> From<&'_ OsStr> for BString[src]

impl<'_> From<&'_ OsString> for BString[src]

impl<'_> From<&'_ String> for BString[src]

impl<'_> From<&'_ str> for BString[src]

impl From<OsString> for BString[src]

impl From<String> for BString[src]

impl Hash for BString[src]

impl Ord for BString[src]

impl<'_> PartialEq<&'_ [u16]> for BString[src]

impl<'_> PartialEq<&'_ BStr> for BString[src]

impl<'_> PartialEq<&'_ OsStr> for BString[src]

impl<'_> PartialEq<&'_ Path> for BString[src]

impl<'_> PartialEq<&'_ str> for BString[src]

impl PartialEq<[u16]> for BString[src]

impl PartialEq<BString> for BString[src]

impl<'_> PartialEq<BString> for &'_ BStr[src]

impl<'_> PartialEq<BString> for &'_ Path[src]

impl PartialEq<BString> for Path[src]

impl PartialEq<BString> for PathBuf[src]

impl<'_> PartialEq<BString> for Cow<'_, [u16]>[src]

impl<'_> PartialEq<BString> for Cow<'_, str>[src]

impl<'_> PartialEq<BString> for Cow<'_, OsStr>[src]

impl<'_> PartialEq<BString> for Cow<'_, Path>[src]

impl<'_> PartialEq<BString> for &'_ str[src]

impl PartialEq<BString> for str[src]

impl<'_> PartialEq<BString> for &'_ [u16][src]

impl PartialEq<BString> for [u16][src]

impl PartialEq<BString> for String[src]

impl<'_> PartialEq<BString> for &'_ OsStr[src]

impl PartialEq<BString> for OsStr[src]

impl PartialEq<BString> for OsString[src]

impl<'_> PartialEq<Cow<'_, [u16]>> for BString[src]

impl<'_> PartialEq<Cow<'_, OsStr>> for BString[src]

impl<'_> PartialEq<Cow<'_, Path>> for BString[src]

impl<'_> PartialEq<Cow<'_, str>> for BString[src]

impl PartialEq<OsStr> for BString[src]

impl PartialEq<OsString> for BString[src]

impl PartialEq<Path> for BString[src]

impl PartialEq<PathBuf> for BString[src]

impl PartialEq<String> for BString[src]

impl PartialEq<str> for BString[src]

impl<'_> PartialOrd<&'_ [u16]> for BString[src]

impl<'_> PartialOrd<&'_ BStr> for BString[src]

impl<'_> PartialOrd<&'_ OsStr> for BString[src]

impl<'_> PartialOrd<&'_ Path> for BString[src]

impl<'_> PartialOrd<&'_ str> for BString[src]

impl PartialOrd<[u16]> for BString[src]

impl PartialOrd<BString> for BString[src]

impl<'_> PartialOrd<BString> for &'_ BStr[src]

impl<'_> PartialOrd<BString> for &'_ Path[src]

impl PartialOrd<BString> for Path[src]

impl PartialOrd<BString> for PathBuf[src]

impl<'_> PartialOrd<BString> for Cow<'_, [u16]>[src]

impl<'_> PartialOrd<BString> for Cow<'_, str>[src]

impl<'_> PartialOrd<BString> for Cow<'_, OsStr>[src]

impl<'_> PartialOrd<BString> for Cow<'_, Path>[src]

impl<'_> PartialOrd<BString> for &'_ str[src]

impl PartialOrd<BString> for str[src]

impl<'_> PartialOrd<BString> for &'_ [u16][src]

impl PartialOrd<BString> for [u16][src]

impl PartialOrd<BString> for String[src]

impl<'_> PartialOrd<BString> for &'_ OsStr[src]

impl PartialOrd<BString> for OsStr[src]

impl PartialOrd<BString> for OsString[src]

impl<'_> PartialOrd<Cow<'_, [u16]>> for BString[src]

impl<'_> PartialOrd<Cow<'_, OsStr>> for BString[src]

impl<'_> PartialOrd<Cow<'_, Path>> for BString[src]

impl<'_> PartialOrd<Cow<'_, str>> for BString[src]

impl PartialOrd<OsStr> for BString[src]

impl PartialOrd<OsString> for BString[src]

impl PartialOrd<Path> for BString[src]

impl PartialOrd<PathBuf> for BString[src]

impl PartialOrd<String> for BString[src]

impl PartialOrd<str> for BString[src]

impl Send for BString[src]

This assumes SysFreeString is thread safe (in the sense that you can call it on a BSTR allocated by another thread.) Considering how much BSTRs are used throughout MTA COM, SysFreeString better be thread safe! While MSDN's documentation is limited on this front, stack overflow confirms:

Q: Is it safe to deallocate a BSTR on a different thread than it was allocated on?
A: [...] All together, it is okay to free string from another thread.

Auto Trait Implementations

impl RefUnwindSafe for BString

impl !Sync for BString

impl Unpin for BString

impl UnwindSafe for BString

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.