pub struct PythonOptions {
pub package: PyPackageConfig,
pub error_base_class: String,
pub module: String,
pub async_methods: bool,
pub keyword_only: bool,
pub public_modules: bool,
pub user_agent: Option<String>,
pub exports: Vec<String>,
}Expand description
Shape of the generated Python (PyO3) API.
The model classes are frozen, eq, with a Python-style repr, and only the models that a
request takes get a keyword constructor. Enums are enum.StrEnum classes (Python 3.11+) in
<package>/_enums.py, without the zero *_UNSPECIFIED member. The extension module is a
declarative #[pymodule] with the proto comments as docs, so PyO3’s introspection
(experimental-inspect) writes the .pyi. The methods block on the Tokio runtime of the
generated codegen/runtime.rs (needs tokio), which the module also installs for the
_async methods. Client errors raise the PyO3 exception classes of the generated
codegen/error.rs, which read them through its ApiErrorAnswer trait: implemented there for
the error of RestClientOptions::error_module, else by the binding crate.
Fields§
§package: PyPackageConfigThe pure-Python package that gets _enums.py and the public modules.
error_base_class: StringName of the base exception class (e.g. MyServiceError): the class with message,
code, status and details that the subclasses per kind of HTTP error status extend.
module: StringThe extension module (e.g. my_pkg._core): the generated #[pymodule]. Classes of a
package a.<service>.v1 go in the submodule <module>.<service>, the root client and
the exceptions in <module>.
async_methods: boolEvery client method also gets a <name>_async twin returning an asyncio.Future. Needs
pyo3-async-runtimes with tokio-runtime.
keyword_only: boolOptional parameters are keyword-only; constructors take REQUIRED fields positionally.
public_modules: boolWrite <package>/<service>.py per submodule of module, re-exporting
its classes and enums.
user_agent: Option<String>The User-Agent product of the Python client (<product>/<binding crate version>).
Needs the reqwest transport.
exports: Vec<String>Hand-written classes and functions of the binding crate (Rust paths, e.g.
crate::extras::PyHelper) that the extension module also exports.
Trait Implementations§
Source§impl Clone for PythonOptions
impl Clone for PythonOptions
Auto Trait Implementations§
impl Freeze for PythonOptions
impl RefUnwindSafe for PythonOptions
impl Send for PythonOptions
impl Sync for PythonOptions
impl Unpin for PythonOptions
impl UnsafeUnpin for PythonOptions
impl UnwindSafe for PythonOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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