Add typed attribute keys: attrs! macro, Attr trait, and typed accessors

This commit is contained in:
Timon
2026-07-18 12:50:56 +00:00
committed by Keavon Chambers
parent 3d7e85c054
commit 58178fd48e
11 changed files with 496 additions and 4 deletions

View File

@@ -0,0 +1,23 @@
//! Typed attribute keys whose value types live in this crate. See `core_types::attr` for the trait and macro.
use graphene_resource::Resource;
node_macro::attrs! {
/// Text item's font, as a resource of the loaded font file.
Font: Resource,
/// Text item's horizontal alignment of lines within the block.
TextAlign: crate::TextAlign,
}
#[cfg(test)]
mod tests {
use super::*;
use core_types::attr::Attr;
// Key names are the stored document format — pinned as literals so a key rename shows up as a breaking change.
#[test]
fn key_names_are_pinned() {
assert_eq!(Font::name(), "font");
assert_eq!(TextAlign::name(), "text_align");
}
}

View File

@@ -1,3 +1,4 @@
pub mod attr;
pub mod fallback;
mod font;
pub mod json;