Cache

Struct Cache 

Source
pub struct Cache<R, C> { /* private fields */ }
Expand description

A Patch store that relies on the cache for reads and as a write-through cache.

The store is used for the main storage when performing a write-through. It is also used for identifying which RepoId is being used for the cache.

Implementations§

Source§

impl<R, C> Cache<R, C>

Source

pub fn new(store: R, cache: C) -> Self

Source

pub fn rid(&self) -> RepoId
where R: HasRepoId,

Source§

impl<'a, R, C> Cache<Patches<'a, R>, C>

Source

pub fn create<'g, G>( &'g mut self, title: Title, description: impl ToString, target: MergeTarget, base: impl Into<Oid>, oid: impl Into<Oid>, labels: &[Label], signer: &Device<G>, ) -> Result<PatchMut<'a, 'g, R, C>, Error>
where R: WriteRepository + Store<Namespace = NodeId>, G: Signer<Signature>, C: Update<Patch>,

Create a new Patch using the super::Patches as the main storage, and writing the update to the cache.

Source

pub fn draft<'g, G>( &'g mut self, title: Title, description: impl ToString, target: MergeTarget, base: impl Into<Oid>, oid: impl Into<Oid>, labels: &[Label], signer: &Device<G>, ) -> Result<PatchMut<'a, 'g, R, C>, Error>
where R: WriteRepository + Store<Namespace = NodeId>, G: Signer<Signature>, C: Update<Patch>,

Create a new Patch, in a draft state, using the super::Patches as the main storage, and writing the update to the cache.

Source

pub fn remove<G>( &mut self, id: &PatchId, signer: &Device<G>, ) -> Result<(), Error>
where G: Signer<Signature>, R: ReadRepository + SignRepository + Store<Namespace = NodeId>, C: Remove<Patch>,

Remove the given id from the super::Patches storage, and removing the entry from the cache.

Source

pub fn write(&mut self, id: &PatchId) -> Result<(), Error>
where R: ReadRepository + Store, C: Update<Patch>,

Read the given id from the super::Patches store and writing it to the cache.

Source

pub fn write_all( &mut self, callback: impl Fn(&Result<(PatchId, Patch), Error>, &Progress) -> ControlFlow<()>, ) -> Result<(), Error>

Read all the patches from the super::Patches store and writing them to cache.

The callback is used for reporting success, failures, and progress to the caller. The caller may also decide to continue or break from the process.

Source§

impl<R> Cache<R, StoreReader>

Source

pub fn reader(store: R, cache: StoreReader) -> Self

Source§

impl<R> Cache<R, StoreWriter>

Source

pub fn open(store: R, cache: StoreWriter) -> Self

Source§

impl<'a, R> Cache<Patches<'a, R>, StoreWriter>
where R: ReadRepository + Store,

Source

pub fn get_mut<'g>( &'g mut self, id: &ObjectId, ) -> Result<PatchMut<'a, 'g, R, StoreWriter>, Error>

Get the PatchMut, identified by id, using the StoreWriter for retrieving the Patch.

Source§

impl<'a, R> Cache<Patches<'a, R>, NoCache>
where R: ReadRepository + Store<Namespace = NodeId>,

Source

pub fn no_cache(repository: &'a R) -> Result<Self, RepositoryError>

Get a Cache that does no write-through modifications and uses the super::Patches store for all reads and writes.

Source

pub fn get_mut<'g>( &'g mut self, id: &ObjectId, ) -> Result<PatchMut<'a, 'g, R, NoCache>, Error>

Get the PatchMut, identified by id.

Trait Implementations§

Source§

impl<R> Patches for Cache<Patches<'_, R>, NoCache>
where R: ReadRepository + Store<Namespace = NodeId>,

Source§

type Error = Error

Source§

type Iter<'b> = NoCacheIter<'b> where Self: 'b

An iterator for returning a set of patches from the store.
Source§

fn get(&self, id: &PatchId) -> Result<Option<Patch>, Self::Error>

Get the Patch, identified by id, returning None if it was not found.
Source§

fn find_by_revision( &self, id: &RevisionId, ) -> Result<Option<ByRevision>, Self::Error>

Get the Patch and its Revision, identified by the revision id, returning None if it was not found.
Source§

fn list(&self) -> Result<Self::Iter<'_>, Self::Error>

List all patches that are in the store.
Source§

fn list_by_status(&self, status: &Status) -> Result<Self::Iter<'_>, Self::Error>

List all patches in the store that match the provided status. Read more
Source§

fn counts(&self) -> Result<PatchCounts, Self::Error>

Get the PatchCounts of all the patches in the store.
Source§

fn opened(&self) -> Result<Self::Iter<'_>, Self::Error>

List all opened patches in the store.
Source§

fn archived(&self) -> Result<Self::Iter<'_>, Self::Error>

List all archived patches in the store.
Source§

fn drafted(&self) -> Result<Self::Iter<'_>, Self::Error>

List all drafted patches in the store.
Source§

fn merged(&self) -> Result<Self::Iter<'_>, Self::Error>

List all merged patches in the store.
Source§

fn is_empty(&self) -> Result<bool, Self::Error>

Returns true if there are no patches in the store.
Source§

impl<R> Patches for Cache<R, StoreReader>
where R: HasRepoId,

Source§

type Error = Error

Source§

type Iter<'b> = PatchesIter<'b> where Self: 'b

An iterator for returning a set of patches from the store.
Source§

fn get(&self, id: &PatchId) -> Result<Option<Patch>, Self::Error>

Get the Patch, identified by id, returning None if it was not found.
Source§

fn find_by_revision(&self, id: &RevisionId) -> Result<Option<ByRevision>, Error>

Get the Patch and its Revision, identified by the revision id, returning None if it was not found.
Source§

fn list(&self) -> Result<Self::Iter<'_>, Self::Error>

List all patches that are in the store.
Source§

fn list_by_status(&self, status: &Status) -> Result<Self::Iter<'_>, Self::Error>

List all patches in the store that match the provided status. Read more
Source§

fn counts(&self) -> Result<PatchCounts, Self::Error>

Get the PatchCounts of all the patches in the store.
Source§

fn opened(&self) -> Result<Self::Iter<'_>, Self::Error>

List all opened patches in the store.
Source§

fn archived(&self) -> Result<Self::Iter<'_>, Self::Error>

List all archived patches in the store.
Source§

fn drafted(&self) -> Result<Self::Iter<'_>, Self::Error>

List all drafted patches in the store.
Source§

fn merged(&self) -> Result<Self::Iter<'_>, Self::Error>

List all merged patches in the store.
Source§

fn is_empty(&self) -> Result<bool, Self::Error>

Returns true if there are no patches in the store.
Source§

impl<R> Patches for Cache<R, StoreWriter>
where R: HasRepoId,

Source§

type Error = Error

Source§

type Iter<'b> = PatchesIter<'b> where Self: 'b

An iterator for returning a set of patches from the store.
Source§

fn get(&self, id: &PatchId) -> Result<Option<Patch>, Self::Error>

Get the Patch, identified by id, returning None if it was not found.
Source§

fn find_by_revision(&self, id: &RevisionId) -> Result<Option<ByRevision>, Error>

Get the Patch and its Revision, identified by the revision id, returning None if it was not found.
Source§

fn list(&self) -> Result<Self::Iter<'_>, Self::Error>

List all patches that are in the store.
Source§

fn list_by_status(&self, status: &Status) -> Result<Self::Iter<'_>, Self::Error>

List all patches in the store that match the provided status. Read more
Source§

fn counts(&self) -> Result<PatchCounts, Self::Error>

Get the PatchCounts of all the patches in the store.
Source§

fn opened(&self) -> Result<Self::Iter<'_>, Self::Error>

List all opened patches in the store.
Source§

fn archived(&self) -> Result<Self::Iter<'_>, Self::Error>

List all archived patches in the store.
Source§

fn drafted(&self) -> Result<Self::Iter<'_>, Self::Error>

List all drafted patches in the store.
Source§

fn merged(&self) -> Result<Self::Iter<'_>, Self::Error>

List all merged patches in the store.
Source§

fn is_empty(&self) -> Result<bool, Self::Error>

Returns true if there are no patches in the store.
Source§

impl<R, C> Remove<Patch> for Cache<R, C>
where C: Remove<Patch>,

Source§

type Out = <C as Remove<Patch>>::Out

The output type, if any, for a successful removal.
Source§

type RemoveError = <C as Remove<Patch>>::RemoveError

Source§

fn remove(&mut self, id: &ObjectId) -> Result<Self::Out, Self::RemoveError>

Delete an object in the COB cache. Read more
Source§

fn remove_all(&mut self, rid: &RepoId) -> Result<Self::Out, Self::RemoveError>

Delete all entries from a repo.
Source§

impl<R, C> Update<Patch> for Cache<R, C>
where C: Update<Patch>,

Source§

type Out = <C as Update<Patch>>::Out

The output type, if any, for a successful update.
Source§

type UpdateError = <C as Update<Patch>>::UpdateError

Source§

fn update( &mut self, rid: &RepoId, id: &ObjectId, object: &Patch, ) -> Result<Self::Out, Self::UpdateError>

Auto Trait Implementations§

§

impl<R, C> Freeze for Cache<R, C>
where R: Freeze, C: Freeze,

§

impl<R, C> RefUnwindSafe for Cache<R, C>

§

impl<R, C> Send for Cache<R, C>
where R: Send, C: Send,

§

impl<R, C> Sync for Cache<R, C>
where R: Sync, C: Sync,

§

impl<R, C> Unpin for Cache<R, C>
where R: Unpin, C: Unpin,

§

impl<R, C> UnwindSafe for Cache<R, C>
where R: UnwindSafe, C: UnwindSafe,

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> PatchesMut for T
where T: Patches + Update<Patch> + Remove<Patch>,