Skip to main content

Chain

Struct Chain 

Source
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>

Source

pub fn id(&self) -> &str

The address the chain is published under: what an agent or a script invokes its actions on.

Source

pub fn parts(&self) -> Vec<(u64, Rc<P::State>)>

Every part this window holds, oldest first, as it stands now.

Source

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.

Source

pub fn revision(&self) -> u64

Increases whenever a held part changed or a newer head arrived.

Source

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.

Source

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.

Source

pub fn waited(&self) -> Vec<(u64, PartArrival)>

Every part asked for and not read here yet, oldest first.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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).

Source

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.

Source

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.

Source

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.

Source

pub fn as_reader(&self, me: &str) -> Self

The same detached chain edited as me: another person’s window over it, in a test.

Source

pub fn part_bytes(&self, index: u64) -> Option<Vec<u8>>

Part index as a document’s bytes, for a tool that carries it to another device itself; None when the chain holds no such part.

Trait Implementations§

Source§

impl<P: Chained> Clone for Chain<P>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AsAny for T
where T: 'static,

§

fn as_any(&self) -> &(dyn Any + 'static)

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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 T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts 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>

Converts 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)

Converts &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)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

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
§

impl<T> ErasedDestructor for T
where T: 'static,