pub struct Chain<P: Chained> { /* private fields */ }Expand description
A chain of records the app keeps beside its own, held for a view or surface. See the module docs.
Implementations§
Source§impl<P: Chained> Chain<P>
impl<P: Chained> Chain<P>
Sourcepub fn id(&self) -> &str
pub fn id(&self) -> &str
The address the chain is published under: what an agent or a script invokes its actions on.
Sourcepub fn parts(&self) -> Vec<(u64, Rc<P::State>)>
pub fn parts(&self) -> Vec<(u64, Rc<P::State>)>
Every part this window holds, oldest first, as it stands now.
Sourcepub fn head(&self) -> Option<u64>
pub fn head(&self) -> Option<u64>
The number of the chain’s head: the newest part held. None while
nothing was written to the chain.
Sourcepub fn hold(&self, index: u64) -> Result<(), String>
pub fn hold(&self, index: u64) -> Result<(), String>
Hold the earlier part index too: read it from this device, or ask
the workspace for it when this device has none of it. Its history merges
in as it arrives (Self::revision moves, the window is woken);
Self::waiting says where it stands until then.
Sourcepub fn waiting(&self, index: u64) -> Option<PartArrival>
pub fn waiting(&self, index: u64) -> Option<PartArrival>
Where part index, asked for and not read here yet, stands: on its
way (a view shows it loading, not empty), or unavailable (a view says
so, with nothing spinning). None once it is read.
Sourcepub fn waited(&self) -> Vec<(u64, PartArrival)>
pub fn waited(&self) -> Vec<(u64, PartArrival)>
Every part asked for and not read here yet, oldest first.
Sourcepub fn apply(&self, action: &P::Action) -> Result<u64, ActionError>
pub fn apply(&self, action: &P::Action) -> Result<u64, ActionError>
Apply action now, as the window’s person, to the part it changes.
The part’s number.
§Errors
As the door refuses it: the person may not, the app’s record or the part refused it.
Sourcepub fn invoke(&self, invoke: &Invoke<P>) -> Result<u64, ActionError>
pub fn invoke(&self, invoke: &Invoke<P>) -> Result<u64, ActionError>
Apply what invoke names now, as Self::apply.
§Errors
As Self::apply, or the arguments do not build the action.
Sourcepub fn undo_in(&self, index: u64) -> Result<(), ActionError>
pub fn undo_in(&self, index: u64) -> Result<(), ActionError>
Take back the window’s person’s last step in part index, through
the part’s history as the undo verb the chain publishes on it does:
the way back a surface offers for a step it took at the person’s own
gesture (Undo beside a message they deleted).
A refusal is reported through the dispatcher’s
refused, as the door’s are.
§Errors
As the door refuses it: the person may not change the part’s history, the part is not here, or they have no step in it to take back.
Sourcepub fn stage_as(
&self,
invoke: &Invoke<P>,
author: &str,
) -> Result<u64, ActionError>
pub fn stage_as( &self, invoke: &Invoke<P>, author: &str, ) -> Result<u64, ActionError>
Apply what invoke names as author wrote it: a screenshot
scenario staging what other people wrote, or a test acting as
someone else. Checked and recorded as Self::apply is, attributed
to author.
§Errors
As Self::invoke.
Sourcepub fn stage_at(
&self,
invoke: &Invoke<P>,
author: &str,
now_ms: i64,
) -> Result<u64, ActionError>
pub fn stage_at( &self, invoke: &Invoke<P>, author: &str, now_ms: i64, ) -> Result<u64, ActionError>
Self::stage_as at now_ms, the action’s time: what someone
wrote at another time.
§Errors
As Self::invoke.
Sourcepub fn write_start(&self, index: u64, state: &P::State) -> Result<(), String>where
P::State: Fields,
pub fn write_start(&self, index: u64, state: &P::State) -> Result<(), String>where
P::State: Fields,
Write state into part index directly, as what the part starts
with: a capture’s or a test’s fixture (items under fixed ids,
written by several people) in fields the parts keep to their own
actions (#[model(readonly)]), which refuse every generic edit.
Not an action: nothing checks who may, nobody is its author, and it
is committed as the part’s genesis, so only a fixture writes it.
Sourcepub fn takes_changes(&self) -> bool
pub fn takes_changes(&self) -> bool
Whether the chain takes a change now: not while a frame reads the
app’s records (a view’s sync), when Self::stage_as waits for a
later pass (an event, a settle pass).
Sourcepub fn dispatcher(&self) -> Dispatcher<P>
pub fn dispatcher(&self) -> Dispatcher<P>
The chain’s dispatcher: what it submits goes through the host’s door
as a click on a control does (a destructive verb asks first), and
apply_now applies at once.
Sourcepub fn detached(
app_id: &'static str,
me: &str,
base: impl Fn() -> Rc<<P::Base as Resource>::State> + 'static,
) -> Option<Self>
pub fn detached( app_id: &'static str, me: &str, base: impl Fn() -> Rc<<P::Base as Resource>::State> + 'static, ) -> Option<Self>
A chain outside any host, for a tool or a test that holds the app’s
records without a window: held in a store of its own, edited as me
(or whoever Self::stage_as names), who may do anything, its
actions reading the app’s record from base. None when P does
not read as a part.
Sourcepub fn detached_in(
store: RecordStore,
app_id: &'static str,
me: &str,
base: impl Fn() -> Rc<<P::Base as Resource>::State> + 'static,
) -> Option<Self>
pub fn detached_in( store: RecordStore, app_id: &'static str, me: &str, base: impl Fn() -> Rc<<P::Base as Resource>::State> + 'static, ) -> Option<Self>
Self::detached, held in store: one device’s records of the
app in a workspace, for a test of what reaches that device’s store from
another one.
Trait Implementations§
Auto Trait Implementations§
impl<P> Freeze for Chain<P>
impl<P> !RefUnwindSafe for Chain<P>
impl<P> !Send for Chain<P>
impl<P> !Sync for Chain<P>
impl<P> Unpin for Chain<P>
impl<P> UnsafeUnpin for Chain<P>
impl<P> !UnwindSafe for Chain<P>
Blanket Implementations§
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more