pyo3::impl_::extract_argument

Struct FunctionDescription

Source
pub struct FunctionDescription {
    pub cls_name: Option<&'static str>,
    pub func_name: &'static str,
    pub positional_parameter_names: &'static [&'static str],
    pub positional_only_parameters: usize,
    pub required_positional_parameters: usize,
    pub keyword_only_parameters: &'static [KeywordOnlyParameterDescription],
}
Expand description

Function argument specification for a #[pyfunction] or #[pymethod].

Fields§

§cls_name: Option<&'static str>§func_name: &'static str§positional_parameter_names: &'static [&'static str]§positional_only_parameters: usize§required_positional_parameters: usize§keyword_only_parameters: &'static [KeywordOnlyParameterDescription]

Implementations§

Source§

impl FunctionDescription

Source

fn full_name(&self) -> String

Source

pub unsafe fn extract_arguments_fastcall<'py, V, K>( &self, py: Python<'py>, args: *const *mut PyObject, nargs: Py_ssize_t, kwnames: *mut PyObject, output: &mut [Option<Borrowed<'py, 'py, PyAny>>], ) -> PyResult<(V::Varargs, K::Varkeywords)>
where V: VarargsHandler<'py>, K: VarkeywordsHandler<'py>,

Available on Py_3_10 or non-Py_LIMITED_API only.

Equivalent of extract_arguments_tuple_dict which uses the Python C-API “fastcall” convention.

§Safety
  • args must be a pointer to a C-style array of valid ffi::PyObject pointers, or NULL.
  • kwnames must be a pointer to a PyTuple, or NULL.
  • nargs + kwnames.len() is the total length of the args array.
Source

pub unsafe fn extract_arguments_tuple_dict<'py, V, K>( &self, py: Python<'py>, args: *mut PyObject, kwargs: *mut PyObject, output: &mut [Option<Borrowed<'py, 'py, PyAny>>], ) -> PyResult<(V::Varargs, K::Varkeywords)>
where V: VarargsHandler<'py>, K: VarkeywordsHandler<'py>,

Extracts the args and kwargs provided into output, according to this function definition.

output must have the same length as this function has positional and keyword-only parameters (as per the positional_parameter_names and keyword_only_parameters respectively).

Unexpected, duplicate or invalid arguments will cause this function to return TypeError.

§Safety
  • args must be a pointer to a PyTuple.
  • kwargs must be a pointer to a PyDict, or NULL.
Source

fn handle_kwargs<'py, K, I>( &self, kwargs: I, varkeywords: &mut K::Varkeywords, num_positional_parameters: usize, output: &mut [Option<Borrowed<'py, 'py, PyAny>>], ) -> PyResult<()>
where K: VarkeywordsHandler<'py>, I: IntoIterator<Item = (Borrowed<'py, 'py, PyAny>, Borrowed<'py, 'py, PyAny>)>,

Source

fn find_keyword_parameter_in_positional( &self, kwarg_name: &str, ) -> Option<usize>

Source

fn find_keyword_parameter_in_keyword_only( &self, kwarg_name: &str, ) -> Option<usize>

Source

fn ensure_no_missing_required_positional_arguments( &self, output: &[Option<Borrowed<'_, '_, PyAny>>], positional_args_provided: usize, ) -> PyResult<()>

Source

fn ensure_no_missing_required_keyword_arguments( &self, output: &[Option<Borrowed<'_, '_, PyAny>>], ) -> PyResult<()>

Source

fn too_many_positional_arguments(&self, args_provided: usize) -> PyErr

Source

fn multiple_values_for_argument(&self, argument: &str) -> PyErr

Source

fn unexpected_keyword_argument( &self, argument: Borrowed<'_, '_, PyAny>, ) -> PyErr

Source

fn positional_only_keyword_arguments(&self, parameter_names: &[&str]) -> PyErr

Source

fn missing_required_arguments( &self, argument_type: &str, parameter_names: &[&str], ) -> PyErr

Source

fn missing_required_keyword_arguments( &self, keyword_outputs: &[Option<Borrowed<'_, '_, PyAny>>], ) -> PyErr

Source

fn missing_required_positional_arguments( &self, output: &[Option<Borrowed<'_, '_, PyAny>>], ) -> PyErr

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AssertNotZeroSized for T

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> SizedTypeProperties for T

Source§

#[doc(hidden)] const IS_ZST: bool = _

🔬This is a nightly-only experimental API. (sized_type_properties)
true if this type requires no storage. false if its size is greater than zero. Read more
Source§

#[doc(hidden)] const LAYOUT: Layout = _

🔬This is a nightly-only experimental API. (sized_type_properties)
Source§

impl<T> SomeWrap<T> for T

Source§

fn wrap(self) -> Option<T>

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> PyClassSync for T
where T: Sync,

Source§

impl<T> Ungil for T
where T: Send,

⚠️ Internal Docs ⚠️ Not Public API 👉 Official Docs Here