Skip to main content

CodegenOptions

Struct CodegenOptions 

Source
pub struct CodegenOptions {
Show 14 fields pub generate_docs: bool, pub generate_default: bool, pub generate_deprecated: bool, pub btree_map: bool, pub use_btree_map: bool, pub package_namespacing: bool, pub type_attributes: BTreeMap<String, Vec<String>>, pub field_attributes: BTreeMap<String, Vec<String>>, pub emit_oxi_message_impl: bool, pub format_output: bool, pub emit_services: bool, pub emit_json: bool, pub emit_builder: bool, pub emit_text_format: bool,
}
Expand description

Options controlling code generation from a FileDescriptorSet.

Fields§

§generate_docs: bool

Generate doc comments from proto source info (default: true)

§generate_default: bool

Generate Default impls for enums (default: true)

§generate_deprecated: bool

Use #[deprecated] for deprecated fields/messages/enums (default: true)

§btree_map: bool

Use BTreeMap for proto map fields instead of HashMap (default: false)

§use_btree_map: bool

Alias for btree_map kept for backward compat with existing tests

§package_namespacing: bool

Emit pub mod hierarchy matching the proto package structure (default: true). When false, all types are emitted flat (no module nesting).

§type_attributes: BTreeMap<String, Vec<String>>

Per-type custom attributes. Key: fully-qualified proto type name. Value: list of attribute strings (e.g., ["#[derive(serde::Serialize)]"]).

§field_attributes: BTreeMap<String, Vec<String>>

Per-field custom attributes. Key: “TypeName.field_name”. Value: list of attribute strings.

§emit_oxi_message_impl: bool

Emit impl OxiMessage for T + impl OxiName for T blocks (default: false). Requires oxiproto-core as a dependency of the crate using generated code.

§format_output: bool

Use prettyplease to format generated code (requires format feature).

§emit_services: bool

Emit pub trait … service definitions (default: true). Set to false to suppress service-trait emission (e.g. --grpc=false in the CLI).

§emit_json: bool

Emit self-contained to_json/from_json methods on generated types (canonical Protobuf-JSON mapping). Requires serde_json and base64 in the consumer crate. Default: false.

§emit_builder: bool

Emit a FooBuilder struct with fluent setters for each message (default: false).

§emit_text_format: bool

Emit a to_text_format() -> String method on each generated message struct (default: false).

Implementations§

Source§

impl CodegenOptions

Source

pub fn new() -> Self

Create options with sensible proto3 defaults.

Source

pub fn use_btree_map_effective(&self) -> bool

Returns true if BTreeMap should be used for map fields.

Trait Implementations§

Source§

impl Clone for CodegenOptions

Source§

fn clone(&self) -> CodegenOptions

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 CodegenOptions

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for CodegenOptions

Source§

fn default() -> Self

Returns the “default value” for a type. 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, 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> 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.