Skip to main content

CodeGenConfig

Struct CodeGenConfig 

Source
pub struct CodeGenConfig {
    pub context_type_path: String,
    pub result_type_path: String,
    pub models_path_template: String,
    pub models_path_crate_template: String,
    pub output: CodeGenOutput,
    pub generate_resource_enum: bool,
    pub generate_store_integration: bool,
    pub error_type_path: Option<String>,
    pub generate_object_conversions: bool,
    pub bindings: Option<BindingsConfig>,
    pub models_gen_dir: Option<String>,
    pub resource_store_crate_name: String,
}
Expand description

Configuration for code generation, including import paths and output directories.

Construct this struct directly and set the fields you need.

Fields§

§context_type_path: String

Fully-qualified path to the request context type used in handler methods.

Default: "crate::api::RequestContext"

§result_type_path: String

Fully-qualified path to the Result alias used in generated handler and client code.

Default: "crate::Result"

§models_path_template: String

Template for the external model import path. {service} is replaced with the service’s base path (e.g. "catalogs").

Example: "my_common::models::{service}::v1"

§models_path_crate_template: String

Template for crate-local model import path. {service} is replaced with the service’s base path.

Default: "crate::models::{service}::v1"

§output: CodeGenOutput

Output directory configuration.

§generate_resource_enum: bool

When true, generate labels.rs with Resource / ObjectLabel enums derived from google.api.resource annotations. Requires output.models to be Some.

Store-specific output (Label impl, RESOURCE_DESCRIPTORS) is only emitted when generate_store_integration is also true.

§generate_store_integration: bool

When true (and generate_resource_enum is set), emit the olai_store integration code in labels.rs:

  • impl olai_store::Label for ObjectLabel
  • pub static RESOURCE_DESCRIPTORS: &[olai_store::ResourceTypeDescriptor<ObjectLabel>]

Set to false for crates that use the enums without a store dependency.

§error_type_path: Option<String>

Fully-qualified path to the Error type used in generated TryFrom<Resource> impls.

E.g. "crate::Error". When None, TryFrom impls are not generated.

§generate_object_conversions: bool

When true and generate_resource_enum is set, emit TryFrom<Object>/TryFrom<T> and ResourceExt impl blocks in labels.rs for all resource types that have an IDENTIFIER-annotated field, plus a qualified_name() inherent method on each resource type.

§bindings: Option<BindingsConfig>

Configuration for language-binding generation. Required when output.python, output.node, or output.node_ts is Some.

§models_gen_dir: Option<String>

Relative path of the prost-generated gen/ dir from the models subdirectory. Required when output.models is Some. E.g. "../gen".

§resource_store_crate_name: String

Crate name for the resource store types used in generated RESOURCE_DESCRIPTORS.

Default: "olai_store"

Implementations§

Source§

impl CodeGenConfig

Source

pub fn validate(&self) -> Result<()>

Validate this config without running code generation.

Checks that:

  • models_path_template and models_path_crate_template produce valid Rust paths after {service} substitution.
  • bindings is Some whenever output.python, output.node, or output.node_ts is Some.

Call this at construction time to surface misconfiguration early, before generation runs.

Trait Implementations§

Source§

impl Clone for CodeGenConfig

Source§

fn clone(&self) -> CodeGenConfig

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 CodeGenConfig

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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