aboutsummaryrefslogtreecommitdiff
path: root/mingling_pathf/test/src/test_files/test_metadata.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-08-04 13:26:48 +0800
committer魏曹先生 <1992414357@qq.com>2026-08-04 13:26:48 +0800
commit4588e17f7ddacd8391a5c881a209735e08d48797 (patch)
tree2b513f4d4f8a18ebd3a34cff7c0fb8abf5787321 /mingling_pathf/test/src/test_files/test_metadata.rs
parentf7862affd74ac3b129f9e9791a4cd4e1c7e3e6d1 (diff)
feat: add entry metadata system with compile-time typed values
Add `Metadata<B>` trait and `#[metadata(Entry)]` attribute macro to attach arbitrary, compile-time-typed metadata to entries. Implement `ProgramCollect::get_metadata<T>()` 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.
Diffstat (limited to 'mingling_pathf/test/src/test_files/test_metadata.rs')
-rw-r--r--mingling_pathf/test/src/test_files/test_metadata.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/mingling_pathf/test/src/test_files/test_metadata.rs b/mingling_pathf/test/src/test_files/test_metadata.rs
new file mode 100644
index 0000000..52a2d4c
--- /dev/null
+++ b/mingling_pathf/test/src/test_files/test_metadata.rs
@@ -0,0 +1,40 @@
+// Root-level metadata functions
+#[mingling::macros::metadata(EntryGreet1)]
+pub fn get_desc1() -> Description1 {
+ Description1 {}
+}
+
+#[metadata(EntryGreet2)]
+fn get_desc2() -> Description2 {
+ Description2 {}
+}
+
+// Local DataType (defined in-crate) + foreign DataType
+#[metadata(EntryGreet3)]
+pub fn get_desc3() -> LocalType3 {
+ LocalType3 {}
+}
+
+use std::collections::HashMap;
+
+#[metadata(EntryGreet4)]
+fn get_desc4() -> HashMap<String, String> {
+ HashMap::new()
+}
+
+#[metadata(EntryGreet5)]
+pub fn get_desc5() -> crate::fully::Qualified5 {
+ crate::fully::Qualified5 {}
+}
+
+pub mod sub {
+ #[mingling::macros::metadata(EntrySub1)]
+ pub fn get_sub1() -> SubType1 {
+ SubType1 {}
+ }
+
+ #[metadata(EntrySub2)]
+ fn get_sub2() -> SubType2 {
+ SubType2 {}
+ }
+}