Trait interoptopus::patterns::success_enum::Success[][src]

pub trait Success {
    const SUCCESS: Self;
    const NULL: Self;
    const PANIC: Self;
}
Expand description

A trait you should implement for enums that signal errors in FFI calls.

The SUCCESS variant will be used to automatically convert Result::Ok values, and NULL when a required pointer was detected to be null.

Example

use interoptopus::patterns::success_enum::Success;

enum FFIError {
    Ok = 0,
    NullPassed = 1,
    Panic = 2,
    OtherError = 3,
}

impl Success for FFIError {
    const SUCCESS: Self = Self::Ok;
    const NULL: Self = Self::NullPassed;
    const PANIC: Self = Self::Panic;
}

Associated Constants

The variant to return when everything went OK, usually the variant with value 0.

Signals a null pointer was passed where an actual element was needed.

The panic variant. Once this is observed no further calls should be attempted.

Implementors