pub struct Live<R: Resource> { /* private fields */ }Expand description
A shared handle to the current state of one resource.
The framework brings the state up to date when the document’s heads move
— a local action, a collaborator’s edit, an undo — reading only what the
change touched (Resource::refresh), and bumps the revision so bound
widgets refresh. Views never write it: edits are actions.
A view of a large resource says what it shows with
demand, and only that is read
(Resource::load).
Implementations§
Source§impl<R: Resource> Live<R>
impl<R: Resource> Live<R>
Sourcepub fn place_of(&self, participant: &ParticipantId) -> Option<Place>
pub fn place_of(&self, participant: &ParticipantId) -> Option<Place>
Where participant’s last action left them, as the resource places
it (Resource::lands): the paragraph an agent appended, the table
it inserted. None before they did anything that lands somewhere.
Sourcepub fn get(&self) -> Rc<R::State>
pub fn get(&self) -> Rc<R::State>
The current state. Cheap: shares the materialised value.
Keep it only as long as a frame needs it. A state still shared when
the document next changes cannot be updated in place, so the
framework reads the whole resource again instead; read through
with or call this again when you need it.
Sourcepub fn unreadable(&self) -> Option<Unreadable>
pub fn unreadable(&self) -> Option<Unreadable>
Why the document stopped reading as the resource, if it did: the state is then the last one that read, and views show this instead.
Sourcepub fn follows(&self, doc: &Doc) -> bool
pub fn follows(&self, doc: &Doc) -> bool
Whether the state is doc as it stands: no change arrived since the
framework last synced it.
Sourcepub fn demand(&self, doc: &Doc, demand: Demand) -> Result<bool, ModelError>
pub fn demand(&self, doc: &Doc, demand: Demand) -> Result<bool, ModelError>
Show the parts of a large resource demand names, reading those not
read yet from doc — the document the view was synced with, which in
History mode is the past version on screen. Returns whether the state
changed.
§Errors
Returns [ModelError] when the document does not hold the resource.
Sourcepub fn current_demand(&self) -> Demand
pub fn current_demand(&self) -> Demand
What views currently demand.
Sourcepub fn sync(&self, doc: &Doc) -> Result<bool, ModelError>
pub fn sync(&self, doc: &Doc) -> Result<bool, ModelError>
Apply what changed in doc since the last sync, reading only what
changed. The framework does this before every frame; a surface calls
it after an immediate edit (Dispatcher::apply_now)
to read its own result within the same event. Returns whether the
state changed.
§Errors
Returns [ModelError] when the document no longer holds the resource.
Trait Implementations§
Auto Trait Implementations§
impl<R> Freeze for Live<R>
impl<R> !RefUnwindSafe for Live<R>
impl<R> !Send for Live<R>
impl<R> !Sync for Live<R>
impl<R> Unpin for Live<R>
impl<R> UnsafeUnpin for Live<R>
impl<R> !UnwindSafe for Live<R>
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> 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