Add StatusCell snapshot, List copy, and interrupt-to-batch conversion

This commit is contained in:
Dennis Kobert
2026-08-18 08:53:38 +00:00
parent b7413dd22c
commit 043f28cc23

View File

@@ -21,6 +21,15 @@ pub enum BatchStatus<'a> {
InvalidRange,
}
impl From<Interrupt> 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<T>,
}
// A shared view regardless of `T`: copying the list copies no elements.
impl<T> Clone for List<'_, T> {
fn clone(&self) -> Self {
*self
}
}
impl<T> 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<T>(self, value: T) -> GPoll<T> {
match (self.error.take(), self.finality.get()) {
(Some(error), _) => GPoll::Fallback(Box::new((value, error))),