Skip to main content

Crate optionable_codegen

Crate optionable_codegen 

Source
Expand description

The relevant main crate is optionable. The docs can be found there.

§Purpose

This code generation proc_macro2 library serves two purposes:

  • Used by optionable_derive to implement the #[derive(Optionable)]-macro re-exported by optionable.
  • Used by the bin/codegen.rs crate to support generating Optionable-implementations for external packages. Due to the orphan rule the generated code has to be added to the Optionable-package (PRs welcome).

It has to be a separate crate from optionable_derive as the proc-macro crates can’t export its non-macro functions (even the proc_macro2 ones) for the usage by the codegen part.

Structs§

CodegenSettings
Settings that are only available to be set via the rust function signature of derive_optionable but not via the derive macro (as they are not useful in that context and would lead to an increased but not useful API surface of the derive macro helpers).

Functions§

attribute_derives
Returns the attribute for setting that the given identifiers should be added as derive macro to the optioned struct/enum.
attribute_no_convert
Returns the attribute for opting-out of OptionableConvert-impl generation.
attribute_suffix
Returns the attribute for setting a custom struct/enum name suffix instead of Opt.
derive_deepmerge
Derives the k8s_openapi::DeepMerge trait.
derive_map_keys_eq
Derives the MapKeysEq trait.
derive_optionable
Derives the Optionable-trait from the main optionable-library.
optioned_ty
Tries to resolve the optioned type analogous to what we do in the main crate. Due to limitations to macro resolving (no order guaranteed) we have to have an explicit list of well-known types and their optioned types. For now limited to self-resolving (mostly primitive) types