pub struct SheetOwner { /* private fields */ }Expand description
Owns one event-loop-confined model, accepted journal, and immutable publication.
Every rejection preserves published views and journal, but discards the live
candidate. Only explicit restoration makes inspection available again.
A fatal propagation error permanently forbids reconstruction and retry.
The Rc factory and views intentionally make no Send or Sync promise.
§Examples
use adam_web_ui::{binding::*, build_sheet};
let mut owner = SheetOwner::new(std::rc::Rc::new(||
build_sheet("sheet s { cell count: i32 = 1; }", "s.adm2")), "s/v1".into()).unwrap();
let edit = CellEdit { key: "count".into(), canonical: "2".into() };
assert!(matches!(owner.apply(&[edit], UpdateOrigin::User), HostOutcome::Accepted));
assert_eq!(owner.views()[0].text, "2");Implementations§
Source§impl SheetOwner
impl SheetOwner
Sourcepub fn new(
factory: ModelFactory,
schema_key: String,
) -> Result<Self, BuildError>
pub fn new( factory: ModelFactory, schema_key: String, ) -> Result<Self, BuildError>
Constructs and publishes one valid initial model without requiring outputs.
§Errors
Returns construction errors or typed publication/capability-read failures.
- Complexity: Factory cost plus publication over all named cells and their contributing graph traversals.
§Examples
See SheetOwner for construction and a transaction.
Sourcepub fn apply(&mut self, edits: &[CellEdit], origin: UpdateOrigin) -> HostOutcome
pub fn apply(&mut self, edits: &[CellEdit], origin: UpdateOrigin) -> HostOutcome
Parses every edit, writes in order, and propagates once before acceptance.
All accepted origins enter recovery history. Only User actions append
enabled recordings; playback and recovery suppress recording feedback.
An empty group is an accepted no-op on a live model and is not journaled.
- Postcondition: Rejection leaves accepted views and history unchanged and makes inspection unavailable until explicit restoration.
- Postcondition: A propagation error retires the owner permanently.
- Postcondition: Recording failure preserves the newly accepted model,
views, and history, stops recording, and returns
RecordingFailed. - Complexity: O(edit bytes + propagation + publication + enabled capture); retained history grows only by the accepted group and new recording, never by a copy of the prior journal.
§Examples
See SheetOwner for submitting a canonical edit.
Sourcepub fn capture(&self, result_keys: &[&str]) -> Result<Recording, CaptureError>
pub fn capture(&self, result_keys: &[&str]) -> Result<Recording, CaptureError>
Captures exact effective sources contributing to the selected stable keys.
Empty selection captures all sources. Source order is unspecified; aliases
use the first registered stable key. Models must satisfy the fixed-point
replay contracts of adam_rs::Sheet::source_cells.
§Errors
Returns explicit result, source identity, codec, encoding, or availability errors.
- Complexity: Source-analysis cost plus expected O(results + keys + sources
- encoded bytes) time and space.
§Examples
use adam_web_ui::{binding::*, build_sheet};
let owner = SheetOwner::new(std::rc::Rc::new(||
build_sheet("sheet s { cell x: i32 = 1; }", "s.adm2")), "s/v1".into()).unwrap();
assert_eq!(owner.capture(&["x"]).unwrap().values[0].canonical, "1");Sourcepub fn start_recording(
&mut self,
result_keys: &[&str],
) -> Result<(), CaptureError>
pub fn start_recording( &mut self, result_keys: &[&str], ) -> Result<(), CaptureError>
Enables subsequent accepted user-action capture after validating selection.
Does not append an initial recording. A failed start preserves prior selection.
§Errors
Returns the same capability, encoding, and availability errors as Self::capture.
- Complexity: Capture cost plus O(result-key bytes) retained space.
§Examples
use adam_web_ui::{binding::*, build_sheet};
let mut owner = SheetOwner::new(std::rc::Rc::new(||
build_sheet("sheet s { cell x: i32 = 1; }", "s.adm2")), "s/v1".into()).unwrap();
owner.start_recording(&["x"]).unwrap();
let outcome = owner.apply(&[CellEdit { key: "x".into(), canonical: "2".into() }],
UpdateOrigin::User);
assert!(matches!(outcome, HostOutcome::Accepted));
assert_eq!(owner.recordings()[0].values[0].canonical, "2");
owner.stop_recording();Sourcepub fn stop_recording(&mut self)
pub fn stop_recording(&mut self)
Stops future action recording without deleting retained recordings.
- Complexity: O(selected result-key bytes) destruction.
§Examples
See Self::start_recording; call owner.stop_recording() to stop capture.
Sourcepub fn recordings(&self) -> &[Rc<Recording>]
pub fn recordings(&self) -> &[Rc<Recording>]
Borrows shared immutable recordings without copying action history.
§Examples
See Self::start_recording; owner.recordings().is_empty() holds before actions.
Sourcepub fn playback(
factory: ModelFactory,
schema_key: String,
recording: &Recording,
) -> Result<Self, PlaybackError>
pub fn playback( factory: ModelFactory, schema_key: String, recording: &Recording, ) -> Result<Self, PlaybackError>
Replays one effective source group on a fresh compatible owner without recording.
Validates schema before construction and decodes every edit before mutation. Writes all values before one propagation and requirement validation.
§Errors
Returns schema, build, rejected-input/requirement, or fatal runtime errors. Fatal failures never trigger a retry or reconstruction.
- Complexity: Factory, transaction, and publication cost plus encoded bytes.
§Examples
use adam_web_ui::{binding::*, build_sheet};
let factory: ModelFactory = std::rc::Rc::new(||
build_sheet("sheet s { cell x: i32 = 1; }", "s.adm2"));
let owner = SheetOwner::new(factory.clone(), "s/v1".into()).unwrap();
let recording = owner.capture(&[]).unwrap();
let replayed = SheetOwner::playback(factory, "s/v1".into(), &recording).unwrap();
assert!(replayed.recordings().is_empty());Sourcepub fn restore_accepted(&mut self) -> Result<(), BuildError>
pub fn restore_accepted(&mut self) -> Result<(), BuildError>
Reconstructs accepted ordered inputs only at the host’s explicit request.
Publication changes only after the factory and every replay group succeed. Failed candidates are discarded, never substituted or inspected.
§Errors
Returns typed construction, replay, or publication failures. A retired owner rejects restoration without calling its factory. A fatal failure during reconstruction or replay permanently retires the owner.
- Complexity: O(history bytes + propagation per group + publication), plus factory and independently owned diagnostic metadata costs.
§Examples
use adam_web_ui::{binding::*, build_sheet};
let mut owner = SheetOwner::new(std::rc::Rc::new(||
build_sheet("sheet s { cell x: i32 = 1; }", "s.adm2")), "s/v1".into()).unwrap();
let _ = owner.apply(&[CellEdit { key: "x".into(), canonical: "bad".into() }],
UpdateOrigin::User);
owner.restore_accepted().unwrap();
assert_eq!(owner.views()[0].text, "1");Sourcepub fn accepted_state(&self) -> &RecoveryState
pub fn accepted_state(&self) -> &RecoveryState
Borrows host-owned accepted history without cloning it.
§Examples
See SheetOwner for construction; a new owner’s transactions are empty.
Sourcepub fn views(&self) -> &[Rc<CellView>]
pub fn views(&self) -> &[Rc<CellView>]
Borrows immutable accepted cell views in stable schema-key order.
Callers may clone individual Rcs without copying the journal or model.
§Examples
See SheetOwner for reading the first published cell.
Sourcepub fn inspect<R>(
&self,
f: impl FnOnce(&ParsedSheet, &Labels) -> R,
) -> Result<R, BindingError>
pub fn inspect<R>( &self, f: impl FnOnce(&ParsedSheet, &Labels) -> R, ) -> Result<R, BindingError>
Invokes a read-only callback only on an accepted live model.
§Errors
Returns a typed unavailable, retired, or reentrant error without invoking the callback when no accepted live model exists.
§Examples
use adam_web_ui::{binding::*, build_sheet};
let owner = SheetOwner::new(std::rc::Rc::new(||
build_sheet("sheet s {}", "s.adm2")), "s/v1".into()).unwrap();
assert_eq!(owner.inspect(|parsed, _| parsed.cell_names.len()).unwrap(), 0);Auto Trait Implementations§
impl !RefUnwindSafe for SheetOwner
impl !Send for SheetOwner
impl !Sync for SheetOwner
impl !UnwindSafe for SheetOwner
impl Freeze for SheetOwner
impl Unpin for SheetOwner
impl UnsafeUnpin for SheetOwner
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
replaced by palette::chromatic_adaptation::AdaptIntoUnclamped
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
replaced by palette::chromatic_adaptation::AdaptIntoUnclamped
Source§impl<T, C> AdaptIntoUnclamped<T> for Cwhere
T: AdaptFromUnclamped<C>,
impl<T, C> AdaptIntoUnclamped<T> for Cwhere
T: AdaptFromUnclamped<C>,
Source§type Scalar = <T as AdaptFromUnclamped<C>>::Scalar
type Scalar = <T as AdaptFromUnclamped<C>>::Scalar
Source§fn adapt_into_unclamped_with<M>(self) -> Twhere
M: LmsToXyz<<C as AdaptIntoUnclamped<T>>::Scalar> + XyzToLms<<C as AdaptIntoUnclamped<T>>::Scalar>,
fn adapt_into_unclamped_with<M>(self) -> Twhere
M: LmsToXyz<<C as AdaptIntoUnclamped<T>>::Scalar> + XyzToLms<<C as AdaptIntoUnclamped<T>>::Scalar>,
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other into Self, while performing the appropriate scaling,
rounding and clamping.§impl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T.Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
Source§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self into T, while performing the appropriate scaling,
rounding and clamping.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
§fn super_from(input: T) -> O
fn super_from(input: T) -> O
§impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
§fn super_into(self) -> O
fn super_into(self) -> O
Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more