Skip to main content

SheetOwner

Struct SheetOwner 

Source
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

Source

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.

Source

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.

Source

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");
Source

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();
Source

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.

Source

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.

Source

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());
Source

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");
Source

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.

Source

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.

Source

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§

Blanket Implementations§

Source§

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
where 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) -> D
where M: TransformMatrix<T>,

👎Deprecated since 0.7.7:

replaced by palette::chromatic_adaptation::AdaptIntoUnclamped

Convert the source color to the destination color using the specified method.
Source§

fn adapt_into(self) -> D

👎Deprecated since 0.7.7:

replaced by palette::chromatic_adaptation::AdaptIntoUnclamped

Convert the source color to the destination color using the bradford method by default.
Source§

impl<T, C> AdaptIntoUnclamped<T> for C
where T: AdaptFromUnclamped<C>,

Source§

type Scalar = <T as AdaptFromUnclamped<C>>::Scalar

The number type that’s used as the color’s components.
Source§

fn adapt_into_unclamped_with<M>(self) -> T

Adapt a color of type Self into a color of type T, using the custom matrix M. Read more
Source§

fn adapt_into_unclamped(self) -> T
where Bradford: LmsToXyz<Self::Scalar> + XyzToLms<Self::Scalar>,

Adapt a color of type Self into a color of type T, using the Bradford matrix. Read more
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T, C> ArraysFrom<C> for T
where C: IntoArrays<T>,

Source§

fn arrays_from(colors: C) -> T

Cast a collection of colors into a collection of arrays.
Source§

impl<T, C> ArraysInto<C> for T
where C: FromArrays<T>,

Source§

fn arrays_into(self) -> C

Cast this collection of arrays into a collection of colors.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for U
where T: FromCam16Unclamped<WpParam, U>,

Source§

type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T, C> ComponentsFrom<C> for T
where C: IntoComponents<T>,

Source§

fn components_from(colors: C) -> T

Cast a collection of colors into a collection of color components.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromAngle<T> for T

Source§

fn from_angle(angle: T) -> T

Performs a conversion from angle.
Source§

impl<T, U> FromStimulus<U> for T
where U: IntoStimulus<T>,

Source§

fn from_stimulus(other: U) -> T

Converts other into Self, while performing the appropriate scaling, rounding and clamping.
§

impl<T> InitializeFromFunction<T> for T

§

fn initialize_from_function(f: fn() -> T) -> T

Create an instance of this type from an initialization function
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> IntoAngle<U> for T
where U: FromAngle<T>,

Source§

fn into_angle(self) -> U

Performs a conversion into T.
Source§

impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for U
where T: Cam16FromUnclamped<WpParam, U>,

Source§

type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<T, U> IntoColor<U> for T
where U: FromColor<T>,

Source§

fn into_color(self) -> U

Convert into T with values clamped to the color defined bounds Read more
Source§

impl<T, U> IntoColorUnclamped<U> for T
where U: FromColorUnclamped<T>,

Source§

fn into_color_unclamped(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
Source§

impl<T> IntoStimulus<T> for T

Source§

fn into_stimulus(self) -> T

Converts self into T, while performing the appropriate scaling, rounding and clamping.
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<Ret> SpawnIfAsync<(), Ret> for Ret

§

fn spawn(self) -> Ret

Spawn the value into the dioxus runtime if it is an async block
§

impl<T, O> SuperFrom<T> for O
where O: From<T>,

§

fn super_from(input: T) -> O

Convert from a type to another type.
§

impl<T, O, M> SuperInto<O, M> for T
where O: SuperFrom<T, M>,

§

fn super_into(self) -> O

Convert from a type to another type.
Source§

impl<T, C> TryComponentsInto<C> for T
where C: TryFromComponents<T>,

Source§

type Error = <C as TryFromComponents<T>>::Error

The error for when try_into_colors fails to cast.
Source§

fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>

Try to cast this collection of color components into a collection of colors. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T, U> TryIntoColor<U> for T
where U: TryFromColor<T>,

Source§

fn try_into_color(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
Source§

impl<C, U> UintsFrom<C> for U
where C: IntoUints<U>,

Source§

fn uints_from(colors: C) -> U

Cast a collection of colors into a collection of unsigned integers.
Source§

impl<C, U> UintsInto<C> for U
where C: FromUints<U>,

Source§

fn uints_into(self) -> C

Cast this collection of unsigned integers into a collection of colors.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more