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<'a, R, C> Cache<Patches<'a, R>, C>
impl<'a, R, C> Cache<Patches<'a, R>, C>
Sourcepub 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>
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>
Create a new Patch using the super::Patches as the
main storage, and writing the update to the cache.
Sourcepub 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>
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>
Create a new Patch, in a draft state, using the
super::Patches as the main storage, and writing the update
to the cache.
Sourcepub 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>,
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.
Sourcepub fn write(&mut self, id: &PatchId) -> Result<(), Error>
pub fn write(&mut self, id: &PatchId) -> Result<(), Error>
Read the given id from the super::Patches store and
writing it to the cache.
Sourcepub fn write_all(
&mut self,
callback: impl Fn(&Result<(PatchId, Patch), Error>, &Progress) -> ControlFlow<()>,
) -> Result<(), Error>
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>
impl<R> Cache<R, StoreReader>
pub fn reader(store: R, cache: StoreReader) -> Self
Source§impl<R> Cache<R, StoreWriter>
impl<R> Cache<R, StoreWriter>
pub fn open(store: R, cache: StoreWriter) -> Self
Source§impl<'a, R> Cache<Patches<'a, R>, StoreWriter>where
R: ReadRepository + Store,
impl<'a, R> Cache<Patches<'a, R>, StoreWriter>where
R: ReadRepository + Store,
Trait Implementations§
Source§impl<R> Patches for Cache<Patches<'_, R>, NoCache>
impl<R> Patches for Cache<Patches<'_, R>, NoCache>
type Error = Error
Source§type Iter<'b> = NoCacheIter<'b>
where
Self: 'b
type Iter<'b> = NoCacheIter<'b> where Self: 'b
Source§fn get(&self, id: &PatchId) -> Result<Option<Patch>, Self::Error>
fn get(&self, id: &PatchId) -> Result<Option<Patch>, Self::Error>
Patch, identified by id, returning None if it
was not found.Source§fn find_by_revision(
&self,
id: &RevisionId,
) -> Result<Option<ByRevision>, Self::Error>
fn find_by_revision( &self, id: &RevisionId, ) -> Result<Option<ByRevision>, Self::Error>
Patch and its Revision, identified by the revision
id, returning None if it was not found.Source§fn list_by_status(&self, status: &Status) -> Result<Self::Iter<'_>, Self::Error>
fn list_by_status(&self, status: &Status) -> Result<Self::Iter<'_>, Self::Error>
status. Read moreSource§fn counts(&self) -> Result<PatchCounts, Self::Error>
fn counts(&self) -> Result<PatchCounts, Self::Error>
PatchCounts of all the patches in the store.Source§fn archived(&self) -> Result<Self::Iter<'_>, Self::Error>
fn archived(&self) -> Result<Self::Iter<'_>, Self::Error>
Source§impl<R> Patches for Cache<R, StoreReader>where
R: HasRepoId,
impl<R> Patches for Cache<R, StoreReader>where
R: HasRepoId,
type Error = Error
Source§type Iter<'b> = PatchesIter<'b>
where
Self: 'b
type Iter<'b> = PatchesIter<'b> where Self: 'b
Source§fn get(&self, id: &PatchId) -> Result<Option<Patch>, Self::Error>
fn get(&self, id: &PatchId) -> Result<Option<Patch>, Self::Error>
Patch, identified by id, returning None if it
was not found.Source§fn find_by_revision(&self, id: &RevisionId) -> Result<Option<ByRevision>, Error>
fn find_by_revision(&self, id: &RevisionId) -> Result<Option<ByRevision>, Error>
Patch and its Revision, identified by the revision
id, returning None if it was not found.Source§fn list_by_status(&self, status: &Status) -> Result<Self::Iter<'_>, Self::Error>
fn list_by_status(&self, status: &Status) -> Result<Self::Iter<'_>, Self::Error>
status. Read moreSource§fn counts(&self) -> Result<PatchCounts, Self::Error>
fn counts(&self) -> Result<PatchCounts, Self::Error>
PatchCounts of all the patches in the store.Source§fn archived(&self) -> Result<Self::Iter<'_>, Self::Error>
fn archived(&self) -> Result<Self::Iter<'_>, Self::Error>
Source§impl<R> Patches for Cache<R, StoreWriter>where
R: HasRepoId,
impl<R> Patches for Cache<R, StoreWriter>where
R: HasRepoId,
type Error = Error
Source§type Iter<'b> = PatchesIter<'b>
where
Self: 'b
type Iter<'b> = PatchesIter<'b> where Self: 'b
Source§fn get(&self, id: &PatchId) -> Result<Option<Patch>, Self::Error>
fn get(&self, id: &PatchId) -> Result<Option<Patch>, Self::Error>
Patch, identified by id, returning None if it
was not found.Source§fn find_by_revision(&self, id: &RevisionId) -> Result<Option<ByRevision>, Error>
fn find_by_revision(&self, id: &RevisionId) -> Result<Option<ByRevision>, Error>
Patch and its Revision, identified by the revision
id, returning None if it was not found.Source§fn list_by_status(&self, status: &Status) -> Result<Self::Iter<'_>, Self::Error>
fn list_by_status(&self, status: &Status) -> Result<Self::Iter<'_>, Self::Error>
status. Read moreSource§fn counts(&self) -> Result<PatchCounts, Self::Error>
fn counts(&self) -> Result<PatchCounts, Self::Error>
PatchCounts of all the patches in the store.