Trait lrs::string::ToCStr

Objects that can be transformed into CStrs provided they have some scratch space available.

Syntax

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>
}

Methods

ReceiverNameDescription
&selfto_cstr

Converts the object by copying it.

&selfto_or_as_cstr

Tries to create a CStr without copying and copies if that's not possible.

&mut selfto_or_as_mut_cstr

Tries to create a mutable CStr without copying and copies if that's not possible.

Remarks

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.