Struct DocWriter
pub struct DocWriter { /* private fields */ }Expand description
Persists one owner’s live document; see the module docs. Failures are
sticky: after one, DocWriter::request sends nothing until a
DocWriter::request_checkpoint full save becomes durable.
A disabled writer persists nothing and reports why, so an app without usable storage runs on the same code path.
Implementations§
§impl DocWriter
impl DocWriter
pub fn try_start(owner: &Rc<DocOwner>) -> Result<DocWriter, StoreError>
pub fn try_start(owner: &Rc<DocOwner>) -> Result<DocWriter, StoreError>
Claim the owner’s one writer, continuing from its accepted document, or from nothing when the owner holds a new one.
§Errors
StoreError::WriterBusy while another writer for this owner lives.
pub fn start_new(
owner: &Rc<DocOwner>,
doc: &mut AutoCommit,
) -> Result<DocWriter, StoreError>
pub fn start_new( owner: &Rc<DocOwner>, doc: &mut AutoCommit, ) -> Result<DocWriter, StoreError>
Start the writer for a new document and submit its first full save.
§Errors
As Self::try_start, or when the store refuses the first write; the
claim is released either way.
pub fn disabled(reason: impl Into<String>) -> DocWriter
pub fn disabled(reason: impl Into<String>) -> DocWriter
A writer that persists nothing; Self::last_error carries reason.
pub fn is_enabled(&self) -> bool
pub fn package_id(&self) -> &str
pub fn package_id(&self) -> &str
The package whose document this is; empty when disabled.
pub fn document_path(&self) -> &Path
pub fn document_path(&self) -> &Path
See [DocOwner::label]; empty when disabled.
pub fn seed(&mut self, doc: &mut AutoCommit)
pub fn seed(&mut self, doc: &mut AutoCommit)
Treat doc as exactly what is already stored: its heads are durable
and later requests append only what follows them.
pub fn request(&mut self, doc: &mut AutoCommit)
pub fn request(&mut self, doc: &mut AutoCommit)
Submit the changes doc has beyond what was last submitted. Cheap when
nothing changed. Does nothing while a failure is outstanding, so a
failed writer never closes the caller’s typing transaction.
pub fn offer(&mut self, doc: &mut AutoCommit) -> Result<(), String>
pub fn offer(&mut self, doc: &mut AutoCommit) -> Result<(), String>
Offer current changes without waiting for host acknowledgement. An accepted replacement may still have a sticky durability failure until its own revision is acknowledged; that is not a submission refusal.
§Errors
Returns a disabled writer or a synchronous store submission refusal.
pub fn request_checkpoint(&mut self, doc: &mut AutoCommit)
pub fn request_checkpoint(&mut self, doc: &mut AutoCommit)
Submit the full current document regardless of what was submitted before — the one write that clears an outstanding failure.
pub fn save(&mut self, doc: &mut AutoCommit)
pub fn save(&mut self, doc: &mut AutoCommit)
Self::request normally, Self::request_checkpoint after a failure.
pub fn durability_snapshot(&self) -> DurabilitySnapshot
pub fn durability_snapshot(&self) -> DurabilitySnapshot
What is durable and whether a failure is outstanding, without submitting or closing anything.
pub fn last_error(&self) -> Option<String>
pub fn try_flush(&self) -> Result<(), String>
pub fn try_flush(&self) -> Result<(), String>
Ask the store to commit everything submitted and report the outcome.
§Errors
The outstanding failure, or writes the store could not yet commit.
pub fn flush(&self)
pub fn flush(&self)
Self::try_flush, logging a failure instead of returning it. Does
nothing for a disabled writer.
pub fn full_writes(&self) -> usize
pub fn appends(&self) -> usize
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for DocWriter
impl !RefUnwindSafe for DocWriter
impl !Send for DocWriter
impl !Sync for DocWriter
impl Unpin for DocWriter
impl UnsafeUnpin for DocWriter
impl !UnwindSafe for DocWriter
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<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