Skip to main content

hydr_structures/structures/actuator/snapshot/
package.rs

1//! Trusted tensor clones and explicit complete caller-owned projection.
2
3use super::super::*;
4use crate::structures::StructureError;
5use numr::dtype::DType;
6use numr::runtime::Runtime;
7
8/// Complete trusted continuation without state projection or recursive history.
9#[derive(Clone, Debug)]
10pub struct GateActuatorSnapshot<R: Runtime<DType = DType>> {
11    pub(super) batch: GateActuatorBatch<R>,
12}
13impl<R: Runtime<DType = DType>> GateActuatorSnapshot<R> {
14    /// Accepted snapshot time in seconds.
15    pub fn time(&self) -> f64 {
16        self.batch.time()
17    }
18    /// Explicitly project the complete caller-owned continuation package.
19    pub fn data(&self) -> Result<GateActuatorSnapshotData, StructureError> {
20        self.batch.snapshot_data()
21    }
22}
23impl<R: Runtime<DType = DType>> GateActuatorBatch<R> {
24    /// Clone complete trusted continuation without derived array readback.
25    pub fn snapshot(&self) -> GateActuatorSnapshot<R> {
26        GateActuatorSnapshot {
27            batch: self.clone(),
28        }
29    }
30    /// Explicitly project complete original inputs and bounded accepted receipts.
31    pub fn snapshot_data(&self) -> Result<GateActuatorSnapshotData, StructureError> {
32        Ok(GateActuatorSnapshotData {
33            schema: GATE_ACTUATOR_SNAPSHOT_SCHEMA.into(),
34            contract: GATE_ACTUATOR_CONTRACT_VERSION.into(),
35            elements: self.elements().to_vec(),
36            definitions: self.definitions().to_vec(),
37            initial_states: self.initial_states().to_vec(),
38            schedule: self.schedule().clone(),
39            time_s: self.time,
40            next_target_index: self.next_target,
41            accepted_steps: self.steps,
42            states: self.states()?,
43            last_step: self.last_step()?,
44        })
45    }
46}