[][src]Struct uapi::Ustr

#[repr(transparent)]pub struct Ustr { /* fields omitted */ }

Thin wrapper for a [u8] that has a trailing nul byte

NOTE: Ustr derefs to Bstr derefs to [u8]. Rustdoc might not show all available methods.

See also the crate documentation.

Implementations

impl Ustr[src]

pub fn empty() -> &'static Self[src]

Returns an empty Ustr

pub fn null() -> &'static Self[src]

Returns the unique &Ustr for which self.is_null() == true

Apart from self.is_null(), the returned value is indistinguishable from Ustr::empty().

pub fn is_null(&self) -> bool[src]

Returns true iff this Ustr was constructed via Ustr::null()

pub unsafe fn from_bytes_unchecked(s: &[u8]) -> &Self[src]

Transmutes the argument into &Ustr

Safety

s must have a trailing nul byte.

pub unsafe fn from_bytes_unchecked_mut(s: &mut [u8]) -> &mut Self[src]

Transmutes the argument into &mut Ustr

Safety

s must have a trailing nul byte.

pub fn from_bytes(s: &[u8]) -> Option<&Self>[src]

Converts the argument into &Ustr after checking that it has a trailing nul byte

Otherwise None is returned.

pub fn from_bytes_mut(s: &mut [u8]) -> Option<&mut Self>[src]

Converts the argument into &mut Ustr after checking that it has a trailing nul byte

Otherwise None is returned.

pub fn as_bytes_with_nul(&self) -> &[u8][src]

Transmutes self into &[u8]

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

Shortcut for Ustr::from_bytes(s.as_bytes())

pub fn from_c_str(s: &CStr) -> &Self[src]

Transmutes the argument into &Ustr

pub unsafe fn from_ptr<'a>(ptr: *const c_char) -> &'a Self[src]

Shortcut for Ustr::from_c_str(CStr::from_ptr(ptr))

Safety

Like CStr::from_ptr

pub unsafe fn from_ptr_mut<'a>(ptr: *mut c_char) -> &'a mut Self[src]

Shortcut for Ustr::from_bytes_unchecked_mut(CStr::from_ptr_mut(ptr).as_bytes_with_nul_mut())

(CStr::from_ptr_mut does not actually exist so check the source if you want to know the truth.)

Safety

Like CStr::from_ptr

pub fn as_c_str(&self) -> Result<&CStr, FromBytesWithNulError>[src]

Shortcut for CStr::from_bytes_with_nul(self.as_bytes_with_nul())

pub fn from_os_str(s: &OsStr) -> Option<&Self>[src]

Shortcut for Ustr::from_bytes(s.as_bytes())

pub fn as_os_str_with_nul(&self) -> &OsStr[src]

Shortcut for OsStr::from_bytes(self.as_bytes_with_nul())

pub fn from_path(s: &Path) -> Option<&Self>[src]

Shortcut for Ustr::from_os_str(s.as_os_str())

pub fn as_path_with_nul(&self) -> &Path[src]

Shortcut for Path::new(self.as_os_str_with_nul())

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

Returns the length of the underlying [u8] including the trailing nul byte

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

Returns the &Bstr created by dropping the trailing nul byte

pub fn as_bstr_mut(&mut self) -> &mut Bstr[src]

Returns the &mut Bstr created by dropping the trailing nul byte

pub fn as_ptr_null(&self) -> *const c_char[src]

Returns ptr::null() if self.is_null(), otherwise self.as_ptr().

Methods from Deref<Target = Bstr>

pub fn as_bytes(&self) -> &[u8][src]

Transmutes self into &[u8]

pub fn as_bytes_mut(&mut self) -> &mut [u8][src]

Transmutes self into &mut [u8]

pub fn as_str(&self) -> Result<&str, Utf8Error>[src]

Shortcut for str::from_utf8(self.as_bytes())

pub fn as_os_str(&self) -> &OsStr[src]

Shortcut for OsStr::from_bytes(self.as_bytes())

pub fn as_path(&self) -> &Path[src]

Shortcut for Path::new(self.as_os_str())

pub fn as_ptr(&self) -> *const c_char[src]

Shortcut for self.as_bytes().as_ptr()

pub fn as_mut_ptr(&mut self) -> *mut c_char[src]

Shortcut for self.as_mut_bytes().as_mut_ptr()

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

Shortcut for self.as_bytes().len()

pub fn is_empty(&self) -> bool[src]

Shortcut for self.len() == 0

pub fn display(&self) -> impl Display + '_[src]

Shortcut for self.as_path().display()

pub fn to_ustring(&self) -> Ustring[src]

Allocates a new Ustring with the contents of this object

Trait Implementations

impl AsMut<[u8]> for Ustr[src]

impl AsRef<[u8]> for Ustr[src]

impl AsRef<OsStr> for Ustr[src]

impl AsRef<Path> for Ustr[src]

impl AsRef<Ustr> for CStr[src]

impl AsUstr for Ustr[src]

impl Borrow<Ustr> for Ustring[src]

impl Debug for Ustr[src]

impl Deref for Ustr[src]

type Target = Bstr

The resulting type after dereferencing.

impl DerefMut for Ustr[src]

impl Eq for Ustr[src]

impl Hash for Ustr[src]

impl<'a> IntoUstr<'a> for &'a Ustr[src]

impl Ord for Ustr[src]

impl PartialEq<[u8]> for Ustr[src]

impl PartialEq<Bstr> for Ustr[src]

impl PartialEq<CStr> for Ustr[src]

impl PartialEq<CString> for Ustr[src]

impl PartialEq<OsStr> for Ustr[src]

impl PartialEq<OsString> for Ustr[src]

impl PartialEq<Path> for Ustr[src]

impl PartialEq<PathBuf> for Ustr[src]

impl PartialEq<String> for Ustr[src]

impl PartialEq<Ustr> for [u8][src]

impl PartialEq<Ustr> for str[src]

impl PartialEq<Ustr> for Bstr[src]

impl PartialEq<Ustr> for Ustring[src]

impl PartialEq<Ustr> for Ustr[src]

impl PartialEq<Ustr> for CStr[src]

impl PartialEq<Ustr> for OsStr[src]

impl PartialEq<Ustr> for Path[src]

impl PartialEq<Ustr> for Vec<u8>[src]

impl PartialEq<Ustr> for String[src]

impl PartialEq<Ustr> for CString[src]

impl PartialEq<Ustr> for OsString[src]

impl PartialEq<Ustr> for PathBuf[src]

impl PartialEq<Ustring> for Ustr[src]

impl PartialEq<Vec<u8>> for Ustr[src]

impl PartialEq<str> for Ustr[src]

impl PartialOrd<Ustr> for Ustr[src]

impl StructuralEq for Ustr[src]

impl StructuralPartialEq for Ustr[src]

impl ToOwned for Ustr[src]

type Owned = Ustring

The resulting type after obtaining ownership.

Auto Trait Implementations

impl RefUnwindSafe for Ustr

impl Send for Ustr

impl Sync for Ustr

impl Unpin for Ustr

impl UnwindSafe for Ustr

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.