rok::bare::ffi
rok::bare::ffi - NUL-terminated C strings (stdlib 1.7.2); wit is
what the WIT bindings run on (1.8).
CStr and CString keep their bytes, NUL included, in one str
object, so as_ptr holds as str::as_ptr does (2.15.2).
CStr::from_ptr copies.
Modules
witrok::bare::ffi::wit - what the generated WIT bindings run on (stdlib 1.8): linear-memory access at canonical ABI addresses (`i32`), the blocks strings and lists lower into, resource handles and `error-context`.
Structs
NulError
pub struct NulErrorAn interior NUL byte, at position (CString::new).
pub position: usize
Trait implementations 3
impl Display for NulErrorimpl Debug for NulErrorimpl Error for NulError
FromBytesWithNulError
pub struct FromBytesWithNulErrorBytes that are not one C string: no final NUL, or one before it.
pub reason: str
Trait implementations 3
impl Display for FromBytesWithNulErrorimpl Debug for FromBytesWithNulErrorimpl Error for FromBytesWithNulError
CStr
pub struct CStrA NUL-terminated string (1.7.2).
pub fn from_ptr(p: ConstPtr<c_char>) -> CStr | noneThe C string at
p(copied in);nonefor a null pointer. Without a NUL terminator the behavior is undefined.pub const fn from_bytes_with_nul(bytes: Slice<u8>) throws (FromBytesWithNulError) -> CStrbyteswhen the last one is the only NUL.pub const fn from_bytes_with_nul_unchecked(bytes: Slice<u8>) -> CStrbytes, whose last byte must be the only NUL (not checked).pub fn as_ptr(self) -> ConstPtr<c_char>pub fn as_bytes(self) -> Slice<u8>The bytes without the NUL.
pub fn as_bytes_with_nul(self) -> Slice<u8>pub fn to_str(self) throws (Utf8Error) -> strpub const fn len(self) -> usizeBytes before the NUL.
CString
pub struct CStringAn owned NUL-terminated string (1.7.2).
pub const fn new(bytes: Slice<u8>) throws (NulError) -> CStringbytesand a NUL; throws ifbyteshas a NUL of its own.pub fn from_str(s: str) throws (NulError) -> CStringpub const fn as_c_str(self) -> CStrpub fn as_ptr(self) -> ConstPtr<c_char>pub fn into_bytes(self) -> List<u8>The bytes without the NUL.
pub fn into_bytes_with_nul(self) -> List<u8>