pub struct NullTermStr<'s> { /* private fields */ }Expand description
Similar to ffi::CStr, except that Self::from_ptr() does not implicitly perform
a libc::strlen().
The stdlib docs note that this is the eventual goal for CStr, but in this case we want to
control where the length measurement is performed, so that we can avoid performing it until we
actually want to use the string data.
Implementations§
Source§impl<'s> NullTermStr<'s>
impl<'s> NullTermStr<'s>
Sourcepub const unsafe fn from_ptr(start: *const c_char) -> Self
pub const unsafe fn from_ptr(start: *const c_char) -> Self
Wrap a null-terminated C-style string, without performing any length calculation or reading any bytes from the pointed-to value.
§Safety
start must be non-null, and point to a contiguous region of memory which ends with
a null byte. This is the same requirement as for ffi::CStr::from_ptr().
Sourcepub const fn as_ptr(&self) -> *const c_char
pub const fn as_ptr(&self) -> *const c_char
Return the input that was provided to Self::from_ptr().
Sourcepub fn measure(self) -> &'s MeasuredNullTermStr
pub fn measure(self) -> &'s MeasuredNullTermStr
Execute libc::strlen() to calculate the length of the pointed-to string.
Sourcepub fn match_dir_entries_unmeasured(&self) -> bool
pub fn match_dir_entries_unmeasured(&self) -> bool
Return whether this matches either of the always-present directory entries "." or "..".
This is performed without any call to strlen(), and will not read past the first null byte.
Trait Implementations§
Source§impl<'s> Clone for NullTermStr<'s>
impl<'s> Clone for NullTermStr<'s>
Source§fn clone(&self) -> NullTermStr<'s>
fn clone(&self) -> NullTermStr<'s>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more