[][src]Struct rustpython_vm::function::PyFuncArgs

pub struct PyFuncArgs {
    pub args: Vec<PyObjectRef>,
    pub kwargs: IndexMap<String, PyObjectRef>,
}

The PyFuncArgs struct is one of the most used structs then creating a rust function that can be called from python. It holds both positional arguments, as well as keyword arguments passed to the function.

Fields

args: Vec<PyObjectRef>kwargs: IndexMap<String, PyObjectRef>

Methods

impl PyFuncArgs[src]

pub fn new(args: Vec<PyObjectRef>, kwarg_names: Vec<String>) -> PyFuncArgs[src]

pub fn insert(&self, item: PyObjectRef) -> PyFuncArgs[src]

pub fn shift(&mut self) -> PyObjectRef[src]

pub fn get_kwarg(&self, key: &str, default: PyObjectRef) -> PyObjectRef[src]

pub fn get_optional_kwarg(&self, key: &str) -> Option<PyObjectRef>[src]

pub fn get_optional_kwarg_with_type(
    &self,
    key: &str,
    ty: PyClassRef,
    vm: &VirtualMachine
) -> Result<Option<PyObjectRef>, PyObjectRef>
[src]

pub fn take_positional(&mut self) -> Option<PyObjectRef>[src]

pub fn take_positional_keyword(&mut self, name: &str) -> Option<PyObjectRef>[src]

pub fn take_keyword(&mut self, name: &str) -> Option<PyObjectRef>[src]

pub fn remaining_keywords<'a>(
    &'a mut self
) -> impl Iterator<Item = (String, PyObjectRef)> + 'a
[src]

pub fn bind<T: FromArgs>(self, vm: &VirtualMachine) -> PyResult<T>[src]

Binds these arguments to their respective values.

If there is an insufficient number of arguments, there are leftover arguments after performing the binding, or if an argument is not of the expected type, a TypeError is raised.

If the given FromArgs includes any conversions, exceptions raised during the conversion will halt the binding and return the error.

Trait Implementations

impl FromArgs for PyFuncArgs[src]

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 Default for PyFuncArgs[src]

impl Clone for PyFuncArgs[src]

impl From<Vec<Rc<PyObject<dyn PyObjectPayload + 'static>>>> for PyFuncArgs[src]

Conversion from vector of python objects to function arguments.

impl From<Rc<PyObject<dyn PyObjectPayload + 'static>>> for PyFuncArgs[src]

impl<'_, '_> From<(&'_ Args<Rc<PyObject<dyn PyObjectPayload + 'static>>>, &'_ KwArgs<Rc<PyObject<dyn PyObjectPayload + 'static>>>)> for PyFuncArgs[src]

impl Debug for PyFuncArgs[src]

Auto Trait Implementations

Blanket Implementations

impl<T> FromArgs for T where
    T: TryFromObject
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self