Skip to main content

Store

Struct Store 

Source
pub struct Store { /* private fields */ }
Expand description

The cache database, shared by the threads of one process.

Implementations§

Source§

impl Store

Source

pub fn open(cache_dir: &Path) -> Result<Self, StoreError>

Opens the database in the db directory of cache_dir, creating it, with the current schema version and the current CacheIdentity, if it does not exist.

An existing database’s schema version is checked first, then its identity.

§Errors

StoreError::SchemaMismatch when the database has another schema version, StoreError::IdentityMismatch when it has another identity, StoreError::IdentityMissing when it has this schema version but no identity, and another StoreError when the database cannot be created or opened.

Source

pub fn inventory(cache_dir: &Path) -> Result<Inventory, StoreError>

Counts the entries of the database in the db directory of cache_dir, whatever its schema version, by their keys alone, and reads its schema version and its identity when it can, without decoding another record or changing anything. A cache without a database has no entries.

§Errors

A StoreError when the database cannot be opened or read.

Source

pub fn wipe(cache_dir: &Path) -> Result<(), StoreError>

Wipes the whole cache database in the db directory of cache_dir, whatever its schema version and identity; the next Store::open creates an empty one, stamped with the current identity. The caller holds the cache lock, so no process has the database open.

The directory is first renamed, in one step, so a crash during the removal leaves no partial database behind, only a directory that the next wipe removes.

§Errors

StoreError::Wipe when the directory cannot be renamed or removed.

Source

pub fn path(&self) -> &Path

The database directory.

Source

pub fn read(&self) -> Result<Txn<'_>, StoreError>

Begins a read-only transaction.

§Errors

StoreError::Database when the database cannot begin one.

Source

pub fn write(&self) -> Result<Txn<'_>, StoreError>

Begins a read-write transaction, which changes nothing until it is committed.

§Errors

StoreError::Database when the database cannot begin one.

Source

pub fn close(self) -> Result<(), StoreError>

Closes the database, after every commit that has started.

§Errors

StoreError::Database when closing fails.

Trait Implementations§

Source§

impl Debug for Store

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Store

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl !Freeze for Store

§

impl !RefUnwindSafe for Store

§

impl !UnwindSafe for Store

§

impl Send for Store

§

impl Sync for Store

§

impl Unpin for Store

§

impl UnsafeUnpin for Store

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
§

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,

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.

§

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
§

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

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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