pub trait IntoCStr: Sized {
type Temp: Deref<Target = CStr>;
// Required methods
fn into(self) -> Self::Temp;
fn into_cstring(self) -> CString;
fn len(&self) -> usize;
// Provided methods
fn is_empty(&self) -> bool { ... }
unsafe fn push_to_non_null_vec(self, bs: &mut Vec<u8>) { ... }
}
Expand description
Represents any type that can be converted into something that can be deref’ed to a &CStr
.
Required Associated Types§
Required Methods§
Sourcefn into_cstring(self) -> CString
fn into_cstring(self) -> CString
Convert this value directly into a CString
.
Provided Methods§
Sourceunsafe fn push_to_non_null_vec(self, bs: &mut Vec<u8>)
unsafe fn push_to_non_null_vec(self, bs: &mut Vec<u8>)
Adds the bytes of the CStr
within to the given Vec
.
SAFETY: Unsafe because we will not check there are no NULs.
Reimplement this if fn into()
does extra allocations.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.