pub struct BlockSync { /* private fields */ }Expand description
One editor’s standing with its block: the value it holds and the history revision it was last in step at, so a frame in which nothing changed costs one integer comparison.
Implementations§
Source§impl BlockSync
impl BlockSync
pub fn new(block: Block) -> Self
pub fn block(&self) -> Block
Sourcepub fn unreported(&mut self, lines: Vec<String>) -> Vec<String>
pub fn unreported(&mut self, lines: Vec<String>) -> Vec<String>
Which of lines this block has not already reported, remembering the
set for next time.
An UNLINKED component is a STANDING state, not an event: the fold reports it on every sheet edit, and one toast per keystroke is noise. A problem that goes and comes back is reported again, which is right — it is news both times.
Sourcepub fn store(
&mut self,
history: &mut History,
value: Value,
coalesce: Option<&str>,
) -> Result<(), String>
pub fn store( &mut self, history: &mut History, value: Value, coalesce: Option<&str>, ) -> Result<(), String>
Write an edit the editor reported: value is the editor’s document
(to_value), coalesce its Change::coalesce. Refused while the
block is Self::unreadable.
Sourcepub fn pulled(&self) -> bool
pub fn pulled(&self) -> bool
Whether Self::pull has run at all: false until the editor first
loads this block, which is the document’s OPEN as far as the editor can
tell (a document is built with its syncs, and a load builds a document).
Sourcepub fn adopt(
&mut self,
history: &mut History,
document: &Value,
value: Value,
) -> Result<(), String>
pub fn adopt( &mut self, history: &mut History, document: &Value, value: Value, ) -> Result<(), String>
Write value as the block with NO undo step: document is the whole
saved document with value already in it, adopted as it stands. For
what the editor did to a block the frame it first loaded it — an older
file brought up to the current shape, which is part of opening it and
not an edit anyone made (see viewport::ecad::store). Refused while
the block is Self::unreadable, as Self::store is.
Sourcepub fn pull(&mut self, history: &History) -> Option<Option<Value>>
pub fn pull(&mut self, history: &History) -> Option<Option<Value>>
The host’s copy when the editor does not hold it: Some(Some(block)),
or Some(None) when the block is absent (never written, or undone past
its first edit), for the editor to load its empty document. None when
the editor is in step. The first call always loads.
Every Some clears Self::unreadable, so the caller owes this after
EACH Some(Some(block)): try to read it (from_value) and call
Self::refuse if that fails. Refusing once and not again on a later
Some lets the stand-in the editor shows be stored over the block.
Sourcepub fn hold_unwritten(&mut self, history: &History, value: Value)
pub fn hold_unwritten(&mut self, history: &History, value: Value)
On a read-only document, the editor’s first frame brought the block up
to the current shape: keep that on screen as held, unwritten. The saved
bytes do not move (History::lock), and the next pull does not undo
what the editor showed on opening.
Sourcepub fn reload(&mut self)
pub fn reload(&mut self)
On a read-only document an edit is taken back: the next Self::pull
loads the stored block again whatever the editor holds.
Sourcepub fn reloads(&self) -> u64
pub fn reloads(&self) -> u64
How many edits a read-only document has taken back from this editor.
Sourcepub fn refused_again(&mut self, value: &Value) -> bool
pub fn refused_again(&mut self, value: &Value) -> bool
Whether value is the edit a read-only document refused last time, so
an editor that reports the same change every frame is told once.
Sourcepub fn refuse(&mut self, reason: String)
pub fn refuse(&mut self, reason: String)
The editor could not read the block Self::pull just handed it.
Sourcepub fn unreadable(&self) -> Option<&str>
pub fn unreadable(&self) -> Option<&str>
Why the block is not being edited, while the editor cannot read it.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BlockSync
impl RefUnwindSafe for BlockSync
impl Send for BlockSync
impl Sync for BlockSync
impl Unpin for BlockSync
impl UnsafeUnpin for BlockSync
impl UnwindSafe for BlockSync
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.