[][src]Trait rustpython_vm::function::IntoPyNativeFunc

pub trait IntoPyNativeFunc<T, R> {
    fn into_func(self) -> PyNativeFunc;
}

Implemented by types that are or can generate built-in functions.

For example, any function that:

  • Accepts a sequence of types that implement FromArgs, followed by a &VirtualMachine
  • Returns some type that implements IntoPyObject

will generate a PyNativeFunc that performs the appropriate type and arity checking, any requested conversions, and then if successful call the function with the bound values.

A bare PyNativeFunc also implements this trait, allowing the above to be done manually, for rare situations that don't fit into this model.

Required methods

Loading content...

Implementors

impl<F> IntoPyNativeFunc<PyFuncArgs, Result<Rc<PyObject<dyn PyObjectPayload + 'static>>, Rc<PyObject<dyn PyObjectPayload + 'static>>>> for F where
    F: Fn(&VirtualMachine, PyFuncArgs) -> PyResult + 'static, 
[src]

impl<F, A, B, C, D, E, R> IntoPyNativeFunc<(OwnedParam<A>, OwnedParam<B>, OwnedParam<C>, OwnedParam<D>, OwnedParam<E>), R> for F where
    F: Fn(A, B, C, D, E, &VirtualMachine) -> R + 'static,
    A: FromArgs,
    B: FromArgs,
    C: FromArgs,
    D: FromArgs,
    E: FromArgs,
    R: IntoPyObject
[src]

impl<F, A, B, C, D, R> IntoPyNativeFunc<(OwnedParam<A>, OwnedParam<B>, OwnedParam<C>, OwnedParam<D>), R> for F where
    F: Fn(A, B, C, D, &VirtualMachine) -> R + 'static,
    A: FromArgs,
    B: FromArgs,
    C: FromArgs,
    D: FromArgs,
    R: IntoPyObject
[src]

impl<F, A, B, C, R> IntoPyNativeFunc<(OwnedParam<A>, OwnedParam<B>, OwnedParam<C>), R> for F where
    F: Fn(A, B, C, &VirtualMachine) -> R + 'static,
    A: FromArgs,
    B: FromArgs,
    C: FromArgs,
    R: IntoPyObject
[src]

impl<F, A, B, R> IntoPyNativeFunc<(OwnedParam<A>, OwnedParam<B>), R> for F where
    F: Fn(A, B, &VirtualMachine) -> R + 'static,
    A: FromArgs,
    B: FromArgs,
    R: IntoPyObject
[src]

impl<F, A, R> IntoPyNativeFunc<(OwnedParam<A>,), R> for F where
    F: Fn(A, &VirtualMachine) -> R + 'static,
    A: FromArgs,
    R: IntoPyObject
[src]

impl<F, R> IntoPyNativeFunc<(), R> for F where
    F: Fn(&VirtualMachine) -> R + 'static,
    R: IntoPyObject
[src]

impl<F, S, A, B, C, D, E, R> IntoPyNativeFunc<(RefParam<S>, OwnedParam<A>, OwnedParam<B>, OwnedParam<C>, OwnedParam<D>, OwnedParam<E>), R> for F where
    F: Fn(&S, A, B, C, D, E, &VirtualMachine) -> R + 'static,
    S: PyValue,
    A: FromArgs,
    B: FromArgs,
    C: FromArgs,
    D: FromArgs,
    E: FromArgs,
    R: IntoPyObject
[src]

impl<F, S, A, B, C, D, R> IntoPyNativeFunc<(RefParam<S>, OwnedParam<A>, OwnedParam<B>, OwnedParam<C>, OwnedParam<D>), R> for F where
    F: Fn(&S, A, B, C, D, &VirtualMachine) -> R + 'static,
    S: PyValue,
    A: FromArgs,
    B: FromArgs,
    C: FromArgs,
    D: FromArgs,
    R: IntoPyObject
[src]

impl<F, S, A, B, C, R> IntoPyNativeFunc<(RefParam<S>, OwnedParam<A>, OwnedParam<B>, OwnedParam<C>), R> for F where
    F: Fn(&S, A, B, C, &VirtualMachine) -> R + 'static,
    S: PyValue,
    A: FromArgs,
    B: FromArgs,
    C: FromArgs,
    R: IntoPyObject
[src]

impl<F, S, A, B, R> IntoPyNativeFunc<(RefParam<S>, OwnedParam<A>, OwnedParam<B>), R> for F where
    F: Fn(&S, A, B, &VirtualMachine) -> R + 'static,
    S: PyValue,
    A: FromArgs,
    B: FromArgs,
    R: IntoPyObject
[src]

impl<F, S, A, R> IntoPyNativeFunc<(RefParam<S>, OwnedParam<A>), R> for F where
    F: Fn(&S, A, &VirtualMachine) -> R + 'static,
    S: PyValue,
    A: FromArgs,
    R: IntoPyObject
[src]

impl<F, S, R> IntoPyNativeFunc<(RefParam<S>,), R> for F where
    F: Fn(&S, &VirtualMachine) -> R + 'static,
    S: PyValue,
    R: IntoPyObject
[src]

Loading content...