Objects that can be transformed into CStrs provided they have some scratch space available.
trait ToCStr {
/* Required methods */
fn to_cstr(&self, buf: &'a mut [u8]) -> Result<&'a mut CStr, Errno>
/* Provided methods */
fn to_or_as_cstr(&'a self, buf: &'a mut [u8]) -> Result<&'a CStr, Errno>
fn to_or_as_mut_cstr(&'a mut self, buf: &'a mut [u8]) -> Result<&'a mut CStr, Errno>
}| Receiver | Name | Description |
|---|---|---|
&self | to_cstr | Converts the object by copying it. |
&self | to_or_as_cstr | Tries to create a |
&mut self | to_or_as_mut_cstr | Tries to create a mutable |
For example, "Hello World" needs to be copied and a 0 appended to form a valid CStr. This operation can fail under the same conditions as AsCStr.