Struct mentat_ffi::utils::error::ExternError [] [src]

#[repr(C)]
pub struct ExternError { pub message: *mut c_char, }

Represents an error that occurred on the mentat side. Many mentat FFI functions take a *mut ExternError as the last argument. This is an out parameter that indicates an error that occurred during that function's execution (if any).

For functions that use this pattern, if the ExternError's message property is null, then no error occurred. If the message is non-null then it contains a string description of the error that occurred.

Important: This message is allocated on the heap and it is the consumer's responsibility to free it using destroy_mentat_string!

While this pattern is not ergonomic in Rust, it offers two main benefits:

  1. It avoids defining a large number of Result-shaped types in the FFI consumer, as would be required with something like an struct ExternResult<T> { ok: *mut T, err:... }
  2. It offers additional type safety over struct ExternResult { ok: *mut c_void, err:... }, which helps avoid memory safety errors.

Fields

Trait Implementations

impl Debug for ExternError
[src]

Formats the value using the given formatter. Read more

impl Default for ExternError
[src]

Returns the "default value" for a type. Read more

Auto Trait Implementations

impl !Send for ExternError

impl !Sync for ExternError