[][src]Trait ffishim::types::Behavior

pub trait Behavior: Sync + Send {
    fn is(&self, sty: &Type) -> bool;
fn fold(&self, sty: Type) -> Type;
fn try_into(&self, sty: &Type, name: Expr) -> Expr;
fn from(&self, sty: &Type, name: Expr) -> Expr;
fn free(&self, sty: &Type, name: Expr) -> Option<Expr>; }

The behavior of a Type as needed to generate the ffi shim.

Required methods

fn is(&self, sty: &Type) -> bool

Returns true if this behavior is fit to handle the given sty.

fn fold(&self, sty: Type) -> Type

Transforms the given Type into its shim equivalent. For example:

  • String -> *mut libc::c_char
  • u32 -> libc::c_uint
  • ...

fn try_into(&self, sty: &Type, name: Expr) -> Expr

Returns an Expression that mutates the shim type into the original one.

fn from(&self, sty: &Type, name: Expr) -> Expr

Returns an Expression that mutates the original type into its shim equivalent.

fn free(&self, sty: &Type, name: Expr) -> Option<Expr>

Returns an Expression that frees an expression of the given type.

Loading content...

Implementors

impl Behavior for ffishim::types::Bool[src]

impl Behavior for ffishim::types::Char[src]

impl Behavior for ffishim::types::Duration[src]

impl Behavior for ffishim::types::Foreign[src]

impl Behavior for ffishim::types::Option[src]

impl Behavior for ffishim::types::Reference[src]

impl Behavior for ffishim::types::Result[src]

impl Behavior for ffishim::types::Scalars[src]

impl Behavior for ffishim::types::String[src]

impl Behavior for ffishim::types::Vector[src]

Loading content...