pub unsafe trait FfiSafeErrorMessage {
// Required method
fn as_ffi_str(&self) -> &'static CStr;
// Provided method
fn as_rust_str(&self) -> &'static str { ... }
}Expand description
A trait to represent a static error message that is represented by both the requirements of Rust strings and C strings:
- It must be a null terminated string with no interior null bytes.
- It must be valid UTF-8.
- It must not allocate to achieve the static bounds.
Using a c-str literal in Rust achieves all these requirements:
c"this string is compatible with FfiSafeErrorMessage";§Safety
The strings returned by as_ffi_str must be valid UTF-8.
Required Methods§
Sourcefn as_ffi_str(&self) -> &'static CStr
fn as_ffi_str(&self) -> &'static CStr
Returns the error message as a static CStr. It must also be a valid Rust string, including being UTF-8.
Provided Methods§
Sourcefn as_rust_str(&self) -> &'static str
fn as_rust_str(&self) -> &'static str
Returns the error message as a static Rust str, excluding the null
terminator. If you need it, use FfiSafeErrorMessage::as_ffi_str.
Do not override this method, it would be marked final if it existed.