pub struct VolumeStore { /* private fields */ }Expand description
Persistent store for volume configurations.
Implementations§
Source§impl VolumeStore
impl VolumeStore
Sourcepub fn new(path: impl Into<PathBuf>, volumes_dir: impl Into<PathBuf>) -> Self
pub fn new(path: impl Into<PathBuf>, volumes_dir: impl Into<PathBuf>) -> Self
Create a new store at the given path.
Sourcepub fn default_path() -> Result<Self>
pub fn default_path() -> Result<Self>
Create a store at the default location (~/.a3s/volumes.json).
Sourcepub fn save(&self, volumes: &HashMap<String, VolumeConfig>) -> Result<()>
pub fn save(&self, volumes: &HashMap<String, VolumeConfig>) -> Result<()>
Save all volumes to disk (atomic write).
Sourcepub fn create(&self, config: VolumeConfig) -> Result<VolumeConfig>
pub fn create(&self, config: VolumeConfig) -> Result<VolumeConfig>
Create a new named volume. Returns the host mount point path.
Creates the volume data directory under ~/.a3s/volumes/<name>/.
Errors if the name already exists (use Self::get_or_create for the
idempotent auto-create on the run -v name:/path path).
Sourcepub fn get_or_create(&self, config: VolumeConfig) -> Result<VolumeConfig>
pub fn get_or_create(&self, config: VolumeConfig) -> Result<VolumeConfig>
Return the existing volume, or create it if absent — atomic under the
cross-process lock. Two concurrent first-time run -v name:/path then
share one volume instead of one racing to an “already exists” error.
Sourcepub fn remove(&self, name: &str, force: bool) -> Result<VolumeConfig>
pub fn remove(&self, name: &str, force: bool) -> Result<VolumeConfig>
Remove a volume by name. Returns error if in use.
Sourcepub fn list(&self) -> Result<Vec<VolumeConfig>>
pub fn list(&self) -> Result<Vec<VolumeConfig>>
List all volumes.
Sourcepub fn update(&self, config: &VolumeConfig) -> Result<()>
pub fn update(&self, config: &VolumeConfig) -> Result<()>
Replace a volume’s config wholesale under the cross-process lock.
For attach/detach prefer Self::modify: a get → mutate → update
reads outside the lock and would lose a concurrent update made between
the two calls.
Sourcepub fn modify<F>(&self, name: &str, f: F) -> Result<bool>where
F: FnOnce(&mut VolumeConfig),
pub fn modify<F>(&self, name: &str, f: F) -> Result<bool>where
F: FnOnce(&mut VolumeConfig),
Atomically mutate one volume’s config under the cross-process lock.
Re-reads the current entry inside the lock so concurrent attach/detach
accumulate correctly — the canonical fix for the split get → mutate →
update race that could drop a volume’s in_use_by entry. Returns
false if the volume does not exist.
Sourcepub fn prune(&self) -> Result<Vec<String>>
pub fn prune(&self) -> Result<Vec<String>>
Remove all volumes that are not in use. Returns names of removed volumes.
Sourcepub fn volume_dir(&self, name: &str) -> PathBuf
pub fn volume_dir(&self, name: &str) -> PathBuf
Get the volume data directory for a named volume.
Trait Implementations§
Source§impl Debug for VolumeStore
impl Debug for VolumeStore
Source§impl VolumeStoreBackend for VolumeStore
impl VolumeStoreBackend for VolumeStore
Source§fn create(&self, config: VolumeConfig) -> Result<VolumeConfig>
fn create(&self, config: VolumeConfig) -> Result<VolumeConfig>
Source§fn remove(&self, name: &str, force: bool) -> Result<VolumeConfig>
fn remove(&self, name: &str, force: bool) -> Result<VolumeConfig>
force is false, returns error if in use.Auto Trait Implementations§
impl Freeze for VolumeStore
impl RefUnwindSafe for VolumeStore
impl Send for VolumeStore
impl Sync for VolumeStore
impl Unpin for VolumeStore
impl UnsafeUnpin for VolumeStore
impl UnwindSafe for VolumeStore
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> 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 more