Struct netcorehost::pdcstring::PdCString
source · 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.
sourcepub fn into_vec(self) -> Vec<PdUChar>
pub fn into_vec(self) -> Vec<PdUChar>
Converts the string into a Vec
without a nul terminator, consuming the string in the process.
sourcepub fn into_vec_with_nul(self) -> Vec<PdUChar>
pub fn into_vec_with_nul(self) -> Vec<PdUChar>
Converts the string into a Vec
, consuming the string in the process.
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.
Trait Implementations§
source§impl Ord for PdCString
impl Ord for PdCString
source§impl PartialEq for PdCString
impl PartialEq for PdCString
source§impl PartialOrd for PdCString
impl PartialOrd for PdCString
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