use std::ffi::OsStr;
use std::fmt;
use std::ops::Deref;
use std::path::{Path, PathBuf};
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct JailedPath {
inner: PathBuf,
}
impl JailedPath {
pub(crate) fn new(path: PathBuf) -> Self {
Self { inner: path }
}
#[inline]
pub fn into_inner(self) -> PathBuf {
self.inner
}
#[inline]
pub fn as_path(&self) -> &Path {
&self.inner
}
}
impl Deref for JailedPath {
type Target = Path;
#[inline]
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl AsRef<Path> for JailedPath {
#[inline]
fn as_ref(&self) -> &Path {
&self.inner
}
}
impl AsRef<OsStr> for JailedPath {
#[inline]
fn as_ref(&self) -> &OsStr {
self.inner.as_os_str()
}
}
impl fmt::Display for JailedPath {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.inner.display())
}
}
impl From<JailedPath> for PathBuf {
#[inline]
fn from(path: JailedPath) -> Self {
path.inner
}
}