pub struct PdCString(/* private fields */);
Expand description
A platform-dependent c-like string type for interacting with the .NET hosting components.
Implementations§
Source§impl PdCString
impl PdCString
Sourcepub fn from_os_str(s: impl AsRef<OsStr>) -> Result<Self, ContainsNul>
pub fn from_os_str(s: impl AsRef<OsStr>) -> Result<Self, ContainsNul>
Sourcepub unsafe fn from_str_ptr(ptr: *const PdChar) -> Self
pub unsafe fn from_str_ptr(ptr: *const PdChar) -> Self
Constructs a new PdCString
copied from a nul-terminated string pointer.
Sourcepub fn from_vec(vec: impl Into<Vec<PdUChar>>) -> Result<Self, ContainsNul>
pub fn from_vec(vec: impl Into<Vec<PdUChar>>) -> Result<Self, ContainsNul>
Constructs a PdCString
from a container of platform-dependent character data.
Methods from Deref<Target = PdCStr>§
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.