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.