Crate rigetti_pyo3

source ·
Expand description

Helpful macros and traits for creating a Python wrapper of a Rust library.

See Macros and Traits for the main items in this crate.

Usage

See the examples directory in the source for example usage of a majority of the crate.

Alternatively, check the examples on the macros in this documentation.

Re-exports

pub use num_complex;
pub use paste;
pub use pyo3;

Modules

Defines DateTime to make converting between Python and time easier.

Macros

Create a crate-private function init_submodule to set up this submodule and call the same function on child modules (which should also use this macro).
Implement AsMut<T> for a Python wrapper around T.
Implement Python comparison for a given type. That type must implement PartialOrd.
Implement FromStr for wrapper types whose inner type implements FromStr.
Implement __hash__ for types that implement Hash.
Implement a method parse for wrapper types that implement FromStr.
Implement __repr__ for wrapper types whose inner type implements Debug.
Implement __str__ for wrapper types whose inner type implements Display.
Implement PyTryFrom for a given Rust type.
Generate PyTryFrom implementations for PyAny that require the PyAny to contain a specific Python type.
Implement PyTryFrom<PyAny> for a given Rust type by delegating to its implementation for the given Python type.
Implement ToPython once for the given Rust type. Will implement for a reference to the type if a lifetime is provided.
Implement ToPython<Py<PyAny>> for a type using its implementation for ToPython<P> where P: ToPyObject.
Implement ToPython on the given Rust type and a reference to it.
(Internal) Helper macro to implement chained conversion through intermediate types, where the type system cannot determine a path from the first to last item.
(Internal) Helper macro to implement chained conversion through intermediate types, where the type system cannot determine a path from the last to first item.
Provides a body for py_try_from, delegating to the implementation for the given Python type.
(Internal) Helper macro to get the final type in a chain of conversions.
Wraps a data struct and makes (some of) its fields available to Python.
Creates a new exception type and implements converting from the given Rust error to the new exception.
Wrap an enum containing only unit variants.
Create a newtype wrapper for a Rust struct.
Create a Python wrapper around a Rust type.
Create a newtype wrapper for a Rust enum with unique 1-tuple variants.
Wraps an external error type in a newtype struct so it can be used with py_wrap_error.

Traits

Convert from a Python type to a Rust type.
Implemented by wrapper types generated with py_wrap_* macros:
Implemented by wrapper types containing the source type, generated with py_wrap_* macros:
Convert from a Rust type into a Python type.
Implemented by error types generated with py_wrap_error.