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: StringFully-qualified path to the request context type used in handler methods.
Default: "crate::api::RequestContext"
result_type_path: StringFully-qualified path to the Result alias used in generated handler and client code.
Default: "crate::Result"
models_path_template: StringTemplate 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: StringTemplate for crate-local model import path. {service} is replaced with the service’s
base path.
Default: "crate::models::{service}::v1"
output: CodeGenOutputOutput directory configuration.
generate_resource_enum: boolWhen 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: boolWhen true (and generate_resource_enum is set), emit the olai_store integration
code in labels.rs:
impl olai_store::Label for ObjectLabelpub 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: boolWhen 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: StringCrate name for the resource store types used in generated RESOURCE_DESCRIPTORS.
Default: "olai_store"
Implementations§
Source§impl CodeGenConfig
impl CodeGenConfig
Sourcepub fn validate(&self) -> Result<()>
pub fn validate(&self) -> Result<()>
Validate this config without running code generation.
Checks that:
models_path_templateandmodels_path_crate_templateproduce valid Rust paths after{service}substitution.bindingsisSomewheneveroutput.python,output.node, oroutput.node_tsisSome.
Call this at construction time to surface misconfiguration early, before generation runs.
Trait Implementations§
Source§impl Clone for CodeGenConfig
impl Clone for CodeGenConfig
Source§fn clone(&self) -> CodeGenConfig
fn clone(&self) -> CodeGenConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for CodeGenConfig
impl RefUnwindSafe for CodeGenConfig
impl Send for CodeGenConfig
impl Sync for CodeGenConfig
impl Unpin for CodeGenConfig
impl UnsafeUnpin for CodeGenConfig
impl UnwindSafe for CodeGenConfig
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