pub use super::tokio_backend::{TokioFile as AndroidFile, TokioLockHandle as AndroidLockHandle};
use super::tokio_backend::TokioVfs;
use std::path::PathBuf;
#[derive(Clone)]
pub struct AndroidVfs {
inner: TokioVfs,
}
impl AndroidVfs {
pub fn new(root: impl Into<PathBuf>) -> Self {
Self {
inner: TokioVfs::new(root),
}
}
#[must_use]
pub fn root_path(&self) -> &std::path::Path {
self.inner.root_path()
}
}
impl std::ops::Deref for AndroidVfs {
type Target = TokioVfs;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl super::traits::Vfs for AndroidVfs {
type File = AndroidFile;
type LockHandle = AndroidLockHandle;
async fn open(&self, path: &str, mode: super::types::OpenMode) -> crate::Result<Self::File> {
self.inner.open(path, mode).await
}
async fn remove(&self, path: &str) -> crate::Result<()> {
self.inner.remove(path).await
}
async fn rename(&self, from: &str, to: &str) -> crate::Result<()> {
self.inner.rename(from, to).await
}
async fn list_dir(&self, path: &str) -> crate::Result<Vec<String>> {
self.inner.list_dir(path).await
}
async fn mkdir_all(&self, path: &str) -> crate::Result<()> {
self.inner.mkdir_all(path).await
}
async fn sync_dir(&self, path: &str) -> crate::Result<()> {
self.inner.sync_dir(path).await
}
async fn lock_exclusive(&self, path: &str) -> crate::Result<Self::LockHandle> {
self.inner.lock_exclusive(path).await
}
async fn lock_shared(&self, path: &str) -> crate::Result<Self::LockHandle> {
self.inner.lock_shared(path).await
}
fn root_path(&self) -> Option<&std::path::Path> {
Some(self.inner.root_path())
}
}