Skip to main content

GridWriter

Struct GridWriter 

Source
pub struct GridWriter<R: GridRow> { /* private fields */ }
Expand description

Writes rows into a GridStore from any thread.

Operations are applied in order by the store’s ingest task. Writing is a short lock and a non-blocking wake-up; it never waits for the UI. Operations written one by one may be published in different snapshots; GridWriter::batch publishes several in one.

Implementations§

Source§

impl<R: GridRow> GridWriter<R>

Source

pub fn batch(&self, write: impl FnOnce(&mut WriteBatch<R>))

Writes the operations of write as one batch: the store applies them in order and publishes them in one snapshot, so no snapshot has some of them without the others. Other writes may share that snapshot. Nothing is written until write returns; then the batch costs one lock and at most one wake-up.

A running reload buffers the batch’s writes until it finishes, as it buffers single ones, but not the batch’s progress, which is never buffered. WriteBatch::finish_reload finishes a reload inside the batch: the reloaded rows and the batch’s writes after it, such as clearing the progress, are published together.

ⓘ
writer.batch(|batch| {
    batch.finish_reload(reload, rows);
    batch.set_progress(None);
});
Source

pub fn begin_reload(&self) -> Reload<R>

Starts a reload: until Reload::finish, operations from every writer are buffered instead of applied. finish(snapshot) hands the snapshot and the buffered operations to the store’s ReloadPolicy (by default the snapshot replaces every row and the buffered operations are replayed on top). Dropping the guard without finish cancels the reload and applies the buffered operations as usual. A newer reload supersedes an older one: the older finish is then ignored.

Source

pub fn upsert(&self, row: impl Into<Arc<R>>)

Inserts or replaces a row by key and highlights the changed columns, each with its GridRow::change_direction.

A new row that changes no column is published all the same, without highlight, so hooks that read other data of the row see it. Writing the same Arc again changes nothing.

Source

pub fn upsert_silent(&self, row: impl Into<Arc<R>>)

Inserts or replaces a row by key without highlight.

Source

pub fn mark_changed(&self, key: R::Key, columns: ColumnSet)

Highlights columns of an existing row without replacing it, without a direction: the values did not change.

Source

pub fn remove(&self, key: R::Key)

Removes a row by key. With a removal fade (HighlightPolicy::with_removal_fade), its last version stays in snapshots as a fading row (StoreSnapshot::fading_row) until the fade ends or the key is written again.

Source

pub fn replace_all(&self, rows: impl IntoIterator<Item = Arc<R>>)

Atomically replaces every row, without highlight.

Source

pub fn clear(&self)

Removes every row.

Source

pub fn set_pinned_rows( &self, edge: PinnedEdge, rows: impl IntoIterator<Item = Arc<R>>, )

Replaces the rows pinned at edge (an empty rows clears the band).

Applied in order with other writes; buffered by a running reload like them. Rows are diffed by key against the previous band: changed columns are highlighted and a new key flashes, except on the first fill of an empty band. A key repeated within rows keeps its last row. Pinned keys are a space of their own, apart from the data rows and the other band. replace_all and clear leave bands alone.

Source

pub fn set_progress(&self, progress: Option<GridProgress>)

Shows (Some) or clears (None) the store’s progress.

Applied in order with other writes, but never buffered by a reload: progress written during a reload shows while the reload runs, and progress cleared after Reload::finish is never cleared before the snapshot that applies the reload. It may be cleared in a later one; to clear it in that very snapshot, write both in one GridWriter::batch with WriteBatch::finish_reload.

Source

pub fn flush(&self) -> impl Future<Output = Option<u64>> + Send + 'static

Resolves once every operation written before the call is applied and published: with that store version (the version of the published snapshot that has them), or None if the store is gone.

The operations waited for are fixed by the call, not by the first poll. Operations buffered by an unfinished reload are not waited for: they are not written to the store until Reload::finish. Each call wakes the ingest task once; an idle store resolves with its current version.

Source

pub fn is_closed(&self) -> bool

Returns true once the store is gone; producers can stop writing.

Source

pub fn snapshot(&self) -> Arc<StoreSnapshot<R>>

The latest published snapshot, for producers that need the current rows (e.g. to patch a row by key). Operations still queued are not in it.

Trait Implementations§

Source§

impl<R: GridRow> Clone for GridWriter<R>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<R> Freeze for GridWriter<R>

§

impl<R> !RefUnwindSafe for GridWriter<R>

§

impl<R> Send for GridWriter<R>

§

impl<R> Sync for GridWriter<R>

§

impl<R> Unpin for GridWriter<R>

§

impl<R> UnsafeUnpin for GridWriter<R>

§

impl<R> !UnwindSafe for GridWriter<R>

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
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> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,