Struct netcorehost::pdcstring::PdCStr
source · pub struct PdCStr(/* private fields */);
Expand description
A borrowed slice of a PdCString
.
Implementations§
source§impl PdCStr
impl PdCStr
sourcepub unsafe fn from_str_ptr<'a>(ptr: *const PdChar) -> &'a Self
pub unsafe fn from_str_ptr<'a>(ptr: *const PdChar) -> &'a Self
Constructs a PdCStr
from a nul-terminated string pointer.
sourcepub fn from_slice_with_nul(
slice: &[PdUChar]
) -> Result<&Self, MissingNulTerminator>
pub fn from_slice_with_nul( slice: &[PdUChar] ) -> Result<&Self, MissingNulTerminator>
Constructs a PdCStr
from a slice of characters with a terminating nul, checking for invalid interior nul values.
sourcepub unsafe fn from_slice_with_nul_unchecked(slice: &[PdUChar]) -> &Self
pub unsafe fn from_slice_with_nul_unchecked(slice: &[PdUChar]) -> &Self
Constructs a PdCStr
from a slice of values without checking for a terminating or interior nul values.
sourcepub fn to_os_string(&self) -> OsString
pub fn to_os_string(&self) -> OsString
Copys the string to an owned OsString
.
sourcepub fn as_slice(&self) -> &[PdUChar]
pub fn as_slice(&self) -> &[PdUChar]
Converts this string to a slice of the underlying elements. The slice will not include the nul terminator.
sourcepub fn as_slice_with_nul(&self) -> &[PdUChar]
pub fn as_slice_with_nul(&self) -> &[PdUChar]
Converts this string to a slice of the underlying elements, including the nul terminator.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns whether this string contains no data (i.e. is only the nul terminator).
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the length of the string as number of elements (not number of bytes) not including the nul terminator.
sourcepub fn to_string(&self) -> Result<String, ToStringError>
pub fn to_string(&self) -> Result<String, ToStringError>
Copies the string to a String
if it contains valid encoded data.
sourcepub fn to_string_lossy(&self) -> String
pub fn to_string_lossy(&self) -> String
Decodes the string to a String
even if it contains invalid data.
Any invalid sequences are replaced with U+FFFD REPLACEMENT CHARACTER, which looks like this: �. It will *not have a nul terminator.
Trait Implementations§
source§impl PartialEq for PdCStr
impl PartialEq for PdCStr
source§impl PartialOrd for PdCStr
impl PartialOrd for PdCStr
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more