Struct rustpython_vm::function::FuncArgs
source · pub struct FuncArgs {
pub args: Vec<PyObjectRef>,
pub kwargs: IndexMap<String, PyObjectRef>,
}
Expand description
The FuncArgs
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>
Implementations§
source§impl FuncArgs
impl FuncArgs
pub fn new<A, K>(args: A, kwargs: K) -> Selfwhere A: Into<PosArgs>, K: Into<KwArgs>,
pub fn with_kwargs_names<A, KW>(args: A, kwarg_names: KW) -> Selfwhere A: ExactSizeIterator<Item = PyObjectRef>, KW: ExactSizeIterator<Item = String>,
pub fn prepend_arg(&mut self, item: PyObjectRef)
pub fn shift(&mut self) -> PyObjectRef
pub fn get_kwarg(&self, key: &str, default: PyObjectRef) -> PyObjectRef
pub fn get_optional_kwarg(&self, key: &str) -> Option<PyObjectRef>
pub fn get_optional_kwarg_with_type( &self, key: &str, ty: PyTypeRef, vm: &VirtualMachine ) -> PyResult<Option<PyObjectRef>>
pub fn take_positional(&mut self) -> Option<PyObjectRef>
pub fn take_positional_keyword(&mut self, name: &str) -> Option<PyObjectRef>
pub fn take_keyword(&mut self, name: &str) -> Option<PyObjectRef>
pub fn remaining_keywords( &mut self ) -> impl Iterator<Item = (String, PyObjectRef)> + '_
sourcepub fn bind<T: FromArgs>(self, vm: &VirtualMachine) -> PyResult<T>
pub fn bind<T: FromArgs>(self, vm: &VirtualMachine) -> PyResult<T>
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.
pub fn check_kwargs_empty( &self, vm: &VirtualMachine ) -> Option<PyBaseExceptionRef>
Trait Implementations§
source§impl<A> From<A> for FuncArgswhere
A: Into<PosArgs>,
impl<A> From<A> for FuncArgswhere A: Into<PosArgs>,
Conversion from vector of python objects to function arguments.
Auto Trait Implementations§
impl !RefUnwindSafe for FuncArgs
impl !Send for FuncArgs
impl !Sync for FuncArgs
impl Unpin for FuncArgs
impl !UnwindSafe for FuncArgs
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more