Skip to main content

Crate xcp_registry_derive

Crate xcp_registry_derive 

Source
Expand description

§xcp_registry_derive

Proc-macro crate providing #[derive(McRegisterType)] and #[derive(McRegisterEnum)].

The derive generates an impl xcp_registry::McRegisterType for T whose register method calls the xcp_registry API directly (add_typedef / add_typedef_field / add_instance), without any intermediate descriptor data structures.

The generated code emits fully-qualified ::xcp_registry::... paths, so the consuming crate must list xcp_registry as a direct dependency in its Cargo.toml, also when it gets the macros through a re-export of another crate such as xcp_lite. This crate itself does not depend on xcp_registry (no dependency cycle), it only emits paths as tokens.

See the design specification in DESIGN.md. Examples are in the documentation of xcp_registry.

§License

Licensed under either of

at your option.

§Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Derive Macros§

McRegisterEnum
Derive McEnumType for an integer enum: reads #[repr(<int>)] and the variant names/discriminants to generate the backing value type and the A2L verbal-conversion unit string. Use #[characteristic(enum_type)] on a field of this enum type to reference it.
McRegisterType
Derive xcp_registry::McRegisterType for a struct The generated register method adds the struct as type definition with all its fields to the registry. Fields can be annotated with #[characteristic(...)], #[axis(...)] or #[measurement(...)], see the crate documentation.