pub trait IntoPyObject<'py>: Sized {
type Target;
type Output: BoundObject<'py, Self::Target>;
type Error: Into<PyErr>;
// Required method
fn into_pyobject(self, py: Python<'py>) -> Result<Self::Output, Self::Error>;
// Provided method
fn type_output() -> TypeInfo { ... }
}
Expand description
Required Associated Types§
Sourcetype Output: BoundObject<'py, Self::Target>
type Output: BoundObject<'py, Self::Target>
The smart pointer type to use.
This will usually be [Bound<'py, Target>
], but in special cases [Borrowed<'a, 'py, Target>
] can be
used to minimize reference counting overhead.
Required Methods§
Provided Methods§
Sourcefn type_output() -> TypeInfo
fn type_output() -> TypeInfo
Extracts the type hint information for this type when it appears as a return value.
For example, Vec<u32>
would return List[int]
.
The default implementation returns Any
, which is correct for any type.
For most types, the return value for this method will be identical to that of FromPyObject::type_input
.
It may be different for some types, such as Dict
, to allow duck-typing: functions return Dict
but take Mapping
as argument.
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.