pub struct OptionDeclMetadata {
pub name: &'static str,
pub doc: &'static str,
pub customizable: bool,
pub group_name: &'static str,
pub type_label: fn() -> &'static str,
pub default_formatted: fn() -> String,
pub type_id: fn() -> TypeId,
pub register_fn: fn(&ConfigRegistry),
}Expand description
Metadata captured at macro expansion for one option. The
register function pointer is monomorphised at the call
site so the registry boot path can register every option
without pulling each <T> into a generic over the slice.
register_fn returns () and inserts the option into the
crate::ConfigRegistry it is handed (via
crate::ConfigRegistry::register_with_typeid);
crate::ConfigRegistry::init_from_linkme calls it once per
element of OPTION_DECLS.
Also the data the browse surfaces read without a registry:
:customize groups by Self::group_name and hides entries
whose Self::customizable is false.
Fields§
§name: &'static strThe option’s OptionDecl::NAME — its :set / TOML key.
doc: &'static strThe option’s OptionDecl::DOC.
customizable: boolThe option’s OptionDecl::CUSTOMIZABLE; false hides it
from :customize.
group_name: &'static strThe owning group’s display name (HasGroup::GROUP_NAME),
which :customize <group> matches against.
type_label: fn() -> &'static str&'static str produced by the value type’s
OptionType::type_label – captured as a function
pointer so the slice element can be a static (the
trait method isn’t const, so calling it directly in
a static initializer fails). Resolved at the registry
boot loop; cheap (one function call per option, once).
default_formatted: fn() -> StringFormat the type’s default value for diagnostic surfaces
(:describe-option “default: X”). Captured as a function
pointer so the slice element stays object-safe-shaped.
type_id: fn() -> TypeIdTypeId::of::<Self>() for the declaration type.
Same as <T as OptionDecl>::type_id() at the macro
call site; pre-computed so the boot loop doesn’t pay
the indirection.
register_fn: fn(&ConfigRegistry)Self-registration thunk. Called by the registry’s
init_from_linkme boot loop with the registry as
argument; the thunk constructs the runtime
crate::option::Option<T> spec via Self::build_spec() and
calls registry.register_with_typeid. The register_fn
is generated by the crate::options! macro and
captures the option’s type identity at compile time.
Boot panics (with the option’s name in the message) if
any registration fails – duplicate names at startup
are a build-config bug.
Implementations§
Source§impl OptionDeclMetadata
impl OptionDeclMetadata
Sourcepub const fn for_decl<D: OptionDecl + HasGroup>(
type_label: fn() -> &'static str,
default_formatted: fn() -> String,
register_fn: fn(&ConfigRegistry),
) -> Self
pub const fn for_decl<D: OptionDecl + HasGroup>( type_label: fn() -> &'static str, default_formatted: fn() -> String, register_fn: fn(&ConfigRegistry), ) -> Self
Construct a metadata record for the given declaration
type. Helper used by the crate::options! macro’s
generated code; not intended for hand-call.