diff --git a/node-graph/libraries/core-types/src/attribute.rs b/node-graph/libraries/core-types/src/attribute.rs index a0693fb34c..f34a433439 100644 --- a/node-graph/libraries/core-types/src/attribute.rs +++ b/node-graph/libraries/core-types/src/attribute.rs @@ -48,7 +48,7 @@ pub trait Attribute: 'static { /// Re-parks the owned clone [`Self::read_erased`] produced into fresh /// field storage; `None` for plain values, which ride the byte copy. - const REPARK: Option Option<()>> = None; + const REPARK: Option = None; } /// A kernel-facing attribute value. A parameter `Attr` is a read of `A` diff --git a/node-graph/libraries/core-types/src/list.rs b/node-graph/libraries/core-types/src/list.rs index 0335da6822..839631f270 100644 --- a/node-graph/libraries/core-types/src/list.rs +++ b/node-graph/libraries/core-types/src/list.rs @@ -85,6 +85,12 @@ pub trait AnyAttributeValue: std::any::Any + Send + Sync { fn into_attribute(self: Box, key: &str, preceding_defaults: usize) -> Box; } +/// Re-parks an owned attribute value into fresh field storage; `None` reports arena exhaustion. +pub type ReparkFn = unsafe fn(&dyn AnyAttributeValue, *mut u8, &crate::arena::Arena) -> Option<()>; + +/// Replays an owned attribute value into a serving arena; `Some(None)` is unchanged, `None` reports arena exhaustion. +pub type FieldReplayFn = fn(&dyn AnyAttributeValue, &crate::arena::Arena) -> Option>>; + impl AnyAttributeValue for T { /// Clones this value into a new boxed trait object. fn clone_box(&self) -> Box { diff --git a/node-graph/libraries/core-types/src/record/layout.rs b/node-graph/libraries/core-types/src/record/layout.rs index ac1813c3a5..721f70e643 100644 --- a/node-graph/libraries/core-types/src/record/layout.rs +++ b/node-graph/libraries/core-types/src/record/layout.rs @@ -15,7 +15,7 @@ pub struct FieldWrite { pub align: usize, pub type_id: std::any::TypeId, pub read_erased: unsafe fn(*const u8) -> Box, - pub repark: Option Option<()>>, + pub repark: Option, /// Hashes the field's content. `None` means the stored bytes are the /// content, which holds for every unparked value. pub content_hash: Option, @@ -64,7 +64,7 @@ pub struct FieldDesc { pub align: usize, pub type_id: std::any::TypeId, pub read_erased: unsafe fn(*const u8) -> Box, - pub repark: Option Option<()>>, + pub repark: Option, /// Hashes the field's content. `None` means the stored bytes are the /// content, which holds for every unparked value. pub content_hash: Option, diff --git a/node-graph/libraries/core-types/src/record/owned.rs b/node-graph/libraries/core-types/src/record/owned.rs index de9ea8a01b..a96c3dd28d 100644 --- a/node-graph/libraries/core-types/src/record/owned.rs +++ b/node-graph/libraries/core-types/src/record/owned.rs @@ -43,7 +43,7 @@ pub(in crate::record) fn deep_element_glue(type_id: std::any::TypeId) -> Option< #[derive(Clone, Copy)] pub(in crate::record) struct DeepFieldGlue { pub(in crate::record) copy_out: fn(&dyn crate::list::AnyAttributeValue) -> Option>, - pub(in crate::record) replay: fn(&dyn crate::list::AnyAttributeValue, &crate::arena::Arena) -> Option>>, + pub(in crate::record) replay: crate::list::FieldReplayFn, } static DEEP_FIELD_VALUES: std::sync::LazyLock>> = std::sync::LazyLock::new(Default::default); @@ -52,7 +52,7 @@ static DEEP_FIELD_VALUES: std::sync::LazyLock( copy_out: fn(&dyn crate::list::AnyAttributeValue) -> Option>, - replay: fn(&dyn crate::list::AnyAttributeValue, &crate::arena::Arena) -> Option>>, + replay: crate::list::FieldReplayFn, ) { DEEP_FIELD_VALUES.lock().unwrap().insert(std::any::TypeId::of::(), DeepFieldGlue { copy_out, replay }); }