Skip to main content

PythonOptions

Struct PythonOptions 

Source
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: PyPackageConfig

The pure-Python package that gets _enums.py and the public modules.

§error_base_class: String

Name 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: String

The 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: bool

Every client method also gets a <name>_async twin returning an asyncio.Future. Needs pyo3-async-runtimes with tokio-runtime.

§keyword_only: bool

Optional parameters are keyword-only; constructors take REQUIRED fields positionally.

§public_modules: bool

Write <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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PythonOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more