pub trait AsRust<T> {
// Required method
fn as_rust(&self) -> Result<T, AsRustError>;
}Expand description
Non-consuming conversion from a #[repr(C)] value back to an
owned, idiomatic Rust value.
AsRust<U> takes &self and returns a freshly-allocated U, copying data
out of any pointer field by borrowing through RawBorrow. The original
C-compatible value is left untouched and its allocations are not freed;
releasing them is the caller’s responsibility.
This is the recommended entry point for values handed to Rust by C — see the crate-level Philosophy.
Required Methods§
Sourcefn as_rust(&self) -> Result<T, AsRustError>
fn as_rust(&self) -> Result<T, AsRustError>
Return a freshly-allocated Rust value equivalent to self.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".