Binding to C++
As an invariant of this API and the static analysis of the cxx::bridge
macro, in Rust code we can never obtain a
CxxString by value. C++'s string
requires a move constructor and may hold internal pointers, which is not
compatible with Rust's move behavior. Instead in Rust code we will only ever
look at a CxxString through a reference or smart pointer, as in
CxxString is not constructible via
new. Instead, use the
Returns the length of the string in bytes.
Matches the behavior of C++ std::string::size.
Returns true if
self has a length of zero bytes.
Matches the behavior of C++ std::string::empty.
Returns a byte slice of this string's contents.
Produces a pointer to the first character of the string.
Matches the behavior of C++ std::string::data.
Note that the return type may look like
const char * but is not a
const char * in the typical C sense, as C++ strings may contain
internal null bytes. As such, the returned pointer only makes sense as a
string in combination with the length returned by
Validates that the C++ string contains UTF-8 data and produces a view of it as a Rust &str, otherwise an error.
pub fn to_string_lossy(&self) -> Cow<'_, str>[src]
If the contents of the C++ string are valid UTF-8, this function returns a view as a Cow::Borrowed &str. Otherwise replaces any invalid UTF-8 sequences with the U+FFFD replacement character and returns a Cow::Owned String.
Appends a given string slice onto the end of this C++ string.
Appends arbitrary bytes onto the end of this C++ string.
impl ExternType for CxxString[src]
impl RefUnwindSafe for CxxString[src]
impl UnwindSafe for CxxString[src]
type Error = Infallible
The type returned in the event of a conversion error.