pub struct Writer { /* private fields */ }Expand description
Writes documents a short while after their last change: each offer of
a new text moves its deadline (delay seconds later, at most five
delays after the first unwritten change); an offer of what was
written last does nothing. Times are the caller’s clock, in seconds
(motion::now in an application). Writes are atomic
(Persist::save_text).
Implementations§
Source§impl Writer
impl Writer
pub fn new(persist: Persist, delay: f64) -> Self
Sourcepub fn offer(&mut self, name: &str, text: String, now: f64) -> bool
pub fn offer(&mut self, name: &str, text: String, now: f64) -> bool
Offers a document’s text: scheduled when it differs from what was written last (or waits already). Whether it is to be written.
Sourcepub fn offer_doc<T: Serialize>(
&mut self,
name: &str,
schema: &Schema,
value: &T,
now: f64,
) -> Result<bool, PersistError>
pub fn offer_doc<T: Serialize>( &mut self, name: &str, schema: &Schema, value: &T, now: f64, ) -> Result<bool, PersistError>
Offers a document at its schema’s current version.
Sourcepub fn written(&mut self, name: &str, text: &str)
pub fn written(&mut self, name: &str, text: &str)
Records that a document’s text is on disk (loaded, or written by someone else): offering it again writes nothing.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Writer
impl RefUnwindSafe for Writer
impl Send for Writer
impl Sync for Writer
impl Unpin for Writer
impl UnsafeUnpin for Writer
impl UnwindSafe for Writer
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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