use std::io;
use std::path::Path;
use crate::MountOptions;
use crate::path::inode_path_bridge::InodePathBridge;
use crate::path::path_filesystem::PathFilesystem;
use crate::raw;
#[cfg(any(feature = "async-io-runtime", feature = "tokio-runtime"))]
#[derive(Debug)]
pub struct Session {
mount_options: MountOptions,
}
#[cfg(any(feature = "async-io-runtime", feature = "tokio-runtime"))]
impl Session {
pub fn new(mount_options: MountOptions) -> Self {
Self { mount_options }
}
#[cfg(feature = "unprivileged")]
pub async fn mount_with_unprivileged<P, FS>(
self,
fs: FS,
mount_path: P,
) -> io::Result<raw::MountHandle>
where
P: AsRef<Path>,
FS: PathFilesystem + Send + Sync + 'static,
{
let bridge = InodePathBridge::new(fs);
raw::Session::new(self.mount_options)
.mount_with_unprivileged(bridge, mount_path)
.await
}
pub async fn mount<P, FS>(self, fs: FS, mount_path: P) -> io::Result<raw::MountHandle>
where
P: AsRef<Path>,
FS: PathFilesystem + Send + Sync + 'static,
{
let bridge = InodePathBridge::new(fs);
raw::Session::new(self.mount_options)
.mount(bridge, mount_path)
.await
}
}