pub trait PyCallArgs<'py>: Sized + Sealed {
// Required methods
#[doc(hidden)] fn call(
self,
function: Borrowed<'_, 'py, PyAny>,
kwargs: Borrowed<'_, 'py, PyDict>,
token: Token,
) -> PyResult<Bound<'py, PyAny>>;
#[doc(hidden)] fn call_positional(
self,
function: Borrowed<'_, 'py, PyAny>,
token: Token,
) -> PyResult<Bound<'py, PyAny>>;
// Provided method
#[doc(hidden)] fn call_method_positional(
self,
object: Borrowed<'_, 'py, PyAny>,
method_name: Borrowed<'_, 'py, PyString>,
_: Token,
) -> PyResult<Bound<'py, PyAny>> { ... }
}
Expand description
This trait marks types that can be used as arguments to Python function calls.
This trait is currently implemented for Rust tuple (up to a size of 12),
[Bound<'py, PyTuple>
] and Py<PyTuple>
. Custom types that are
convertable to PyTuple
via IntoPyObject
need to do so before passing it
to call
.
This trait is not intended to used by downstream crates directly. As such it
has no publicly available methods and cannot be implemented ouside of
pyo3
. The corresponding public API is available through call
(call0
, call1
and friends) on PyAnyMethods
.
§What is PyCallArgs
used for?
PyCallArgs
is used internally in pyo3
to dispatch the Python calls in
the most optimal way for the current build configuration. Certain types,
such as Rust tuples, do allow the usage of a faster calling convention of
the Python interpreter (if available). More types that may take advantage
from this may be added in the future.
Required Methods§
#[doc(hidden)] fn call( self, function: Borrowed<'_, 'py, PyAny>, kwargs: Borrowed<'_, 'py, PyDict>, token: Token, ) -> PyResult<Bound<'py, PyAny>>
#[doc(hidden)] fn call_positional( self, function: Borrowed<'_, 'py, PyAny>, token: Token, ) -> PyResult<Bound<'py, PyAny>>
Provided Methods§
#[doc(hidden)] fn call_method_positional( self, object: Borrowed<'_, 'py, PyAny>, method_name: Borrowed<'_, 'py, PyString>, _: Token, ) -> PyResult<Bound<'py, PyAny>>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.