pub enum Volume {
ContainerVolume {
name: VolumeName,
container: PathBuf,
readonly: bool,
},
BindMount {
container: PathBuf,
host: PathBuf,
readonly: bool,
},
Tmpfs {
container: PathBuf,
},
}
Expand description
A volume
See Docker reference
§Examples
// Create a bind mount volumes
let v1 = Volume::from(("./data", "/etc/var/data"));
let v2 = Volume::bind_mount("./data", "/etc/var/data");
assert_eq!(v1, v2);
// Create a container volume
let name = "my-vol".parse::<VolumeName>().expect("a valid volume name");
let v1 = Volume::from((name.clone(), "/etc/var/data"));
let v2 = Volume::container_volume(name, "/etc/var/data");
assert_eq!(v1, v2);
// Create a tmpfs volume (in-memory)
let v = Volume::tmpfs("/etc/var/data");
assert!(matches!(v, Volume::Tmpfs{..}));
Variants§
ContainerVolume
A containervolume
Fields
§
name: VolumeName
The name
BindMount
A bind mount
Fields
Tmpfs
In-Memory mount
⚠️ WARNING, this is not supported by all platform See https://docs.docker.com/storage/tmpfs
Implementations§
Source§impl Volume
impl Volume
Sourcepub fn container_volume(name: VolumeName, container: impl Into<PathBuf>) -> Self
pub fn container_volume(name: VolumeName, container: impl Into<PathBuf>) -> Self
Create a container volume
Trait Implementations§
Source§impl<P> From<(VolumeName, P)> for Volume
impl<P> From<(VolumeName, P)> for Volume
Source§fn from(value: (VolumeName, P)) -> Self
fn from(value: (VolumeName, P)) -> Self
Converts to this type from the input type.
impl Eq for Volume
impl StructuralPartialEq for Volume
Auto Trait Implementations§
impl Freeze for Volume
impl RefUnwindSafe for Volume
impl Send for Volume
impl Sync for Volume
impl Unpin for Volume
impl UnwindSafe for Volume
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.