Enum cfixed_string::CFixedString [−][src]
pub enum CFixedString {
Local {
s: [c_char; 512],
len: usize,
},
Heap {
s: CString,
len: usize,
},
}
Expand description
This is a C String abstractions that presents a CStr like interface for interop purposes but tries to be little nicer by avoiding heap allocations if the string is within the generous bounds (512 bytes) of the statically sized buffer. Strings over this limit will be heap allocated, but the interface outside of this abstraction remains the same.
Variants
Implementations
Creates an empty CFixedString, this is intended to be
used with write! or the fmt::Write
trait
Returns true if the string has been heap allocated
Converts a CFixedString
into a Cow<str>
.
This function will calculate the length of this string (which normally
requires a linear amount of work to be done) and then return the
resulting slice as a Cow<str>
, replacing any invalid UTF-8 sequences
with U+FFFD REPLACEMENT CHARACTER
. If there are no invalid UTF-8
sequences, this will merely return a borrowed slice.
Trait Implementations
Performs the conversion.
Writes a string slice into this writer, returning whether the write succeeded. Read more