diff --git a/node-graph/libraries/core-types/src/node.rs b/node-graph/libraries/core-types/src/node.rs index f9fe7b8b3e..a139b9e757 100644 --- a/node-graph/libraries/core-types/src/node.rs +++ b/node-graph/libraries/core-types/src/node.rs @@ -21,6 +21,15 @@ pub enum BatchStatus<'a> { InvalidRange, } +impl From for BatchStatus<'_> { + fn from(interrupt: Interrupt) -> Self { + match interrupt { + Interrupt::Pending => BatchStatus::Pending, + Interrupt::Error(error) => BatchStatus::Error(*error), + } + } +} + /// A shared view over a batch of records in one flat frame buffer: lane `i` /// starts at `frames + i * stride` with `stride = layout.lane_stride()`. /// Frame bytes carry no drop glue (droppable elements ride parked, @@ -177,6 +186,15 @@ pub struct List<'a, T> { _element: PhantomData, } +// A shared view regardless of `T`: copying the list copies no elements. +impl Clone for List<'_, T> { + fn clone(&self) -> Self { + *self + } +} + +impl Copy for List<'_, T> {} + impl<'a, T> List<'a, T> { /// # Safety /// `T` must be the batch's record element type, proven at the consumer's wiring. @@ -446,6 +464,18 @@ impl StatusCell { } } + /// A new cell holding a copy of the accumulated status; the error stays in + /// place, cloned rather than taken. + pub fn snapshot(&self) -> StatusCell { + let error = self.error.take(); + self.error.set(error.clone()); + StatusCell { + finality: Cell::new(self.finality.get()), + error: Cell::new(error), + no_partial: self.no_partial, + } + } + pub fn finish(self, value: T) -> GPoll { match (self.error.take(), self.finality.get()) { (Some(error), _) => GPoll::Fallback(Box::new((value, error))),