From da8ae2be43430b1fb27c7732f46709fa1c229f40 Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Fri, 21 Aug 2026 19:34:02 +0000 Subject: [PATCH] Tag record layouts with their element type --- node-graph/libraries/core-types/src/record.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/node-graph/libraries/core-types/src/record.rs b/node-graph/libraries/core-types/src/record.rs index a216dd3075..419b89c16b 100644 --- a/node-graph/libraries/core-types/src/record.rs +++ b/node-graph/libraries/core-types/src/record.rs @@ -91,6 +91,7 @@ pub struct ElementWrite { pub size: usize, pub align: usize, pub parked: bool, + pub type_id: std::any::TypeId, pub clone_out: unsafe fn(*const u8) -> Box, pub repark: unsafe fn(&(dyn std::any::Any + Send + Sync), *mut u8, &crate::arena::Arena) -> Option<()>, /// Hashes the element's content. `None` means the stored bytes are the @@ -120,6 +121,7 @@ impl Default for ElementWrite { size: 0, align: 0, parked: false, + type_id: std::any::TypeId::of::<()>(), clone_out, repark, content_hash: None, @@ -1164,6 +1166,7 @@ pub fn element_write() -> ElementWrite { size, align, parked: element_parked::(), + type_id: std::any::TypeId::of::(), clone_out: clone_out::, repark: repark::, content_hash: None, @@ -1625,6 +1628,16 @@ impl GroupItem { // SAFETY: `adopt` filled `len` lanes of `layout` at the layout's stride. unsafe { crate::node::RecordBatch::new(self.frames, self.len, &self.layout) } } + + /// A typed view over the stored records, checked against the layout's + /// element type. + pub fn typed_lanes(&self) -> Option> { + match self.layout.element.type_id == std::any::TypeId::of::() { + // SAFETY: the layout records the element type the lanes hold. + true => Some(unsafe { crate::node::List::new(self.lanes()) }), + false => None, + } + } } /// The records a group stores: a single homogeneous run, or a list of