From 4588e17f7ddacd8391a5c881a209735e08d48797 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Tue, 4 Aug 2026 13:26:48 +0800 Subject: feat: add entry metadata system with compile-time typed values Add `Metadata` trait and `#[metadata(Entry)]` attribute macro to attach arbitrary, compile-time-typed metadata to entries. Implement `ProgramCollect::get_metadata()` for runtime retrieval, backed by a global registry populated by `register_metadata!`. Extend `pathf` with `MetadataPattern` to resolve metadata types across modules at build time. Add two examples demonstrating metadata usage with and without pathf integration. --- docs/example-pages/examples.json | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'docs') diff --git a/docs/example-pages/examples.json b/docs/example-pages/examples.json index bde9d35..31336f1 100644 --- a/docs/example-pages/examples.json +++ b/docs/example-pages/examples.json @@ -94,6 +94,24 @@ "Cargo.toml" ] }, + { + "id": "example-combine-pathf-metadata", + "name": "Pathfinder + Metadata", + "icon": "🧭", + "category": "advanced", + "desc": "Combines the `pathf` feature with entry metadata. The metadata `DataType` and the entry `BindType` are defined inside a submodule, and `pathf` resolves them for `gen_program!()` at build time.\n", + "tags": [ + "pathf", + "metadata", + "build.rs" + ], + "files": [ + "src/main.rs", + "src/sub/mod.rs", + "build.rs", + "Cargo.toml" + ] + }, { "id": "example-command-macro", "name": "Command Macro", @@ -253,6 +271,22 @@ "Cargo.toml" ] }, + { + "id": "example-metadata", + "name": "Entry Metadata", + "icon": "🏷️", + "category": "advanced", + "desc": "Demonstrates attaching arbitrary, compile-time-typed metadata to an entry via `#[metadata(Entry)]` and retrieving it at runtime with `ProgramCollect::get_metadata`. No `pathf` needed here — everything lives in a single module.\n", + "tags": [ + "metadata", + "get_metadata", + "extras" + ], + "files": [ + "src/main.rs", + "Cargo.toml" + ] + }, { "id": "example-outside-type", "name": "Outside Type", -- cgit