Struct utf8_cstr::Utf8CStr
[−]
[src]
pub struct Utf8CStr {
// some fields omitted
}A wrapper that promises it's contents are null-terminated & validly utf-8 encoded
Plain std::ffi::CStr only promises null termination, but some ffi (and other bits) require
strings that are both valid utf8 and null terminated.
Methods
impl Utf8CStr[src]
fn from_cstr(v: &CStr) -> Result<&Utf8CStr, Utf8Error>
Failable convertion from a CStr.
NOTE: Only handles non-mutable variants. We may want to accept &mut as well in the future.
fn from_bytes(b: &[u8]) -> Result<&Utf8CStr, Utf8CStrError>
Convert directly from bytes
NOTE: right now this scans b a few times over. Ideally, we'd adjust it to only scan b
once.
unsafe fn from_bytes_with_nul_unchecked(b: &[u8]) -> &Utf8CStr
Raw convertion from basic data type with no checking.