[−][src]Struct uapi::Ustr
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]
pub unsafe fn from_bytes_unchecked_mut(s: &mut [u8]) -> &mut Self
[src]
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]
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]
impl DerefMut for Ustr
[src]
impl Eq for Ustr
[src]
impl Hash for Ustr
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,