1use std::path::Path;
2
3use async_trait::async_trait;
4
5use crate::error::Result;
6use crate::types::{FileEntry, FileMeta};
7
8#[async_trait]
10pub trait RemoteFileSystem: Send {
11 async fn connect(&mut self) -> Result<()>;
13
14 async fn disconnect(&mut self) -> Result<()>;
16
17 fn is_connected(&self) -> bool;
19
20 async fn list(&mut self, path: &str) -> Result<Vec<FileEntry>>;
22
23 async fn metadata(&mut self, path: &str) -> Result<FileMeta>;
25
26 async fn exists(&mut self, path: &str) -> Result<bool>;
28
29 async fn mkdir(&mut self, path: &str) -> Result<()>;
31
32 async fn mkdir_all(&mut self, path: &str) -> Result<()>;
34
35 async fn rmdir(&mut self, path: &str) -> Result<()>;
37
38 async fn remove_file(&mut self, path: &str) -> Result<()>;
40
41 async fn remove(&mut self, path: &str) -> Result<()>;
43
44 async fn rename(&mut self, from: &str, to: &str) -> Result<()>;
46
47 async fn read(&mut self, path: &str) -> Result<Vec<u8>>;
49
50 async fn write(&mut self, path: &str, data: &[u8]) -> Result<()>;
52
53 async fn download(&mut self, remote: &str, local: &Path) -> Result<()>;
55
56 async fn upload(&mut self, local: &Path, remote: &str) -> Result<()>;
58}