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) -> Self
pub fn with_kwargs_names<A, KW>(args: A, kwarg_names: KW) -> Self
pub fn is_empty(&self) -> bool
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§
Auto Trait Implementations§
impl Freeze for FuncArgs
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more