pub struct InstanceStateHandle { /* private fields */ }
state-dir
only.Expand description
State or cache directory for an instance of a facility
Implies exclusive access:
there is only one InstanceStateHandle
at a time,
across any number of processes, tasks, and threads,
for the same instance.
§Key uniqueness and syntactic restrictions
Methods on InstanceStateHandle
typically take a TryIntoSlug
.
It is important that keys are distinct within an instance.
Specifically:
each key provided to a method on the same InstanceStateHandle
(or a clone of it)
must be different.
Violating this rule does not result in memory-unsafety,
but might result in incorrect operation due to concurrent filesystem access,
including possible data loss and corruption.
(Typically, the key is fixed, and the StorageHandle
s are usually
obtained during instance construction, so ensuring this is straightforward.)
There are also syntactic restrictions on keys. See slug.
Implementations§
Source§impl InstanceStateHandle
impl InstanceStateHandle
Sourcepub fn storage_handle<T>(
&self,
key: &(impl TryIntoSlug + ?Sized),
) -> Result<StorageHandle<T>>
pub fn storage_handle<T>( &self, key: &(impl TryIntoSlug + ?Sized), ) -> Result<StorageHandle<T>>
Obtain a StorageHandle
, usable for storing/retrieving a T
Sourcepub fn raw_subdir(
&self,
key: &(impl TryIntoSlug + ?Sized),
) -> Result<InstanceRawSubdir>
pub fn raw_subdir( &self, key: &(impl TryIntoSlug + ?Sized), ) -> Result<InstanceRawSubdir>
Obtain a raw filesystem subdirectory, within the directory for this instance
This API is unsuitable platforms without a filesystem accessible via std::fs
.
May therefore only be used within Arti for features
where we’re happy to not to support such platforms (eg WASM without WASI)
without substantial further work.
Sourcepub fn purge(self) -> Result<()>
pub fn purge(self) -> Result<()>
Unconditionally delete this instance directory
For expiry, use StateDirectory::purge_instances
,
and then call this in the dispose
method.
Will return a BadAPIUsage
if other clones of this InstanceStateHandle
exist.
§Deletion is not atomic
If a deletion operation doesn’t complete for any reason (maybe it was interrupted, or there was a filesystem access problem), part of the instance contents may remain.
After such an interrupted deletion,
storage items (StorageHandle
) are might each independently
be deleted (load
returns None
)
or retained (Some
).
Deletion of the contents of raw subdirectories
(InstanceStateHandle::raw_subdir
)
is done with std::fs::remove_dir_all
.
If deletion is interrupted, the raw subdirectory may contain partial contents.
Trait Implementations§
Source§impl Clone for InstanceStateHandle
impl Clone for InstanceStateHandle
Source§fn clone(&self) -> InstanceStateHandle
fn clone(&self) -> InstanceStateHandle
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl ContainsInstanceStateGuard for InstanceStateHandle
impl ContainsInstanceStateGuard for InstanceStateHandle
Source§fn raw_lock_guard(&self) -> Arc<LockFileGuard>
fn raw_lock_guard(&self) -> Arc<LockFileGuard>
Auto Trait Implementations§
impl Freeze for InstanceStateHandle
impl RefUnwindSafe for InstanceStateHandle
impl Send for InstanceStateHandle
impl Sync for InstanceStateHandle
impl Unpin for InstanceStateHandle
impl UnwindSafe for InstanceStateHandle
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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 moreSource§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 88 bytes