MCPcopy Create free account
hub / github.com/dgrunwald/rust-cpython / FromPyObject

Interface FromPyObject

src/conversion.rs:102–105  ·  view source on GitHub ↗

FromPyObject is implemented by various types that can be extracted from a Python object. Normal usage is through the `PyObject::extract` helper method: ```let obj: PyObject = ...; let value = obj.extract:: (py)?; ``` Each target type for this conversion supports a different Python objects as input. Calls with an unsupported input object will result in an exception (usually a `TypeErro

Source from the content-addressed store, hash-verified

100/// When these macros are used with reference parameters (`x: &str`), the trait
101/// `RefFromPyObject` is used instead.
102pub trait FromPyObject<'s>: Sized {
103 /// Extracts `Self` from the source `PyObject`.
104 fn extract(py: Python, obj: &'s PyObject) -> PyResult<Self>;
105}
106
107py_impl_from_py_object_for_python_object!(PyObject);
108

Callers

nothing calls this directly

Implementers 4

conversion.rssrc/conversion.rs
string.rssrc/objects/string.rs
sequence.rssrc/objects/sequence.rs
none.rssrc/objects/none.rs

Calls

no outgoing calls

Tested by

no test coverage detected