pub struct MountRoot {
pub host_root: PathBuf,
pub container_root: ContainerPath,
}Expand description
Declarative host/container root pair used to create validated child mounts.
Fields§
§host_root: PathBufBase directory on the host.
container_root: ContainerPathDirectory the host root maps to inside the container.
Implementations§
Source§impl MountRoot
impl MountRoot
Sourcepub fn new(host_root: impl Into<PathBuf>, container_root: ContainerPath) -> Self
pub fn new(host_root: impl Into<PathBuf>, container_root: ContainerPath) -> Self
Pairs a host directory with the container path it maps to.
Sourcepub fn child(
&self,
relative: impl AsRef<Path>,
access: MountAccess,
) -> Result<MountSpec, MountRootError>
pub fn child( &self, relative: impl AsRef<Path>, access: MountAccess, ) -> Result<MountSpec, MountRootError>
Derives a mount for a path beneath this root.
§Errors
Returns MountRootError if relative is empty, absolute, or contains
a .. component — any of which would place the mount outside the root —
or if a component is not UTF-8.
Sourcepub fn container_path(
&self,
host: &Path,
) -> Result<ContainerPath, MountRootError>
pub fn container_path( &self, host: &Path, ) -> Result<ContainerPath, MountRootError>
Where the host path host, the root itself or a path beneath it,
appears inside the container.
§Errors
Returns MountRootError::OutsideRoot if host is not beneath the
root, and the conditions of Self::child for what lies beneath it.
Sourcepub fn host_path(
&self,
container: &ContainerPath,
) -> Result<PathBuf, MountRootError>
pub fn host_path( &self, container: &ContainerPath, ) -> Result<PathBuf, MountRootError>
Where the container path container, the container root itself or a
path beneath it, lies on the host.
§Errors
Returns MountRootError::OutsideContainerRoot if container is not
beneath the container root, and MountRootError::ParentTraversal if
what lies beneath it contains ...
Sourcepub fn read_only_child(
&self,
relative: impl AsRef<Path>,
) -> Result<MountSpec, MountRootError>
pub fn read_only_child( &self, relative: impl AsRef<Path>, ) -> Result<MountSpec, MountRootError>
Sourcepub fn read_write_child(
&self,
relative: impl AsRef<Path>,
) -> Result<MountSpec, MountRootError>
pub fn read_write_child( &self, relative: impl AsRef<Path>, ) -> Result<MountSpec, MountRootError>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for MountRoot
impl<'de> Deserialize<'de> for MountRoot
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for MountRoot
Source§impl JsonSchema for MountRoot
impl JsonSchema for MountRoot
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreimpl StructuralPartialEq for MountRoot
Auto Trait Implementations§
impl Forget for MountRoot
impl Freeze for MountRoot
impl Move for MountRoot
impl RefUnwindSafe for MountRoot
impl Send for MountRoot
impl Sync for MountRoot
impl Unpin for MountRoot
impl UnsafeUnpin for MountRoot
impl UnwindSafe for MountRoot
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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
key and return true if they are equal.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