fluvio_future/fs/
mod.rs

1mod bounded;
2mod extension;
3
4pub use extension::*;
5
6pub use self::bounded::BoundedFileOption;
7pub use self::bounded::BoundedFileSink;
8pub use self::bounded::BoundedFileSinkError;
9
10#[cfg(feature = "mmap")]
11pub mod mmap;
12
13pub use async_fs::*;
14
15pub mod util {
16
17    use std::io::Error as IoError;
18    use std::path::Path;
19
20    use super::File;
21    use super::OpenOptions;
22
23    /// open for write only
24    pub async fn create<P>(path: P) -> Result<File, IoError>
25    where
26        P: AsRef<Path>,
27    {
28        File::create(path.as_ref()).await
29    }
30
31    /// open for only read
32    pub async fn open<P>(path: P) -> Result<File, IoError>
33    where
34        P: AsRef<Path>,
35    {
36        let file_path = path.as_ref();
37        File::open(file_path).await
38    }
39
40    /// open for read and write
41    pub async fn open_read_write<P>(path: P) -> Result<File, IoError>
42    where
43        P: AsRef<Path>,
44    {
45        let file_path = path.as_ref();
46        let mut option = OpenOptions::new();
47        option.read(true).write(true).create(true).append(false);
48
49        option.open(file_path).await
50    }
51
52    pub async fn open_read_append<P>(path: P) -> Result<File, IoError>
53    where
54        P: AsRef<Path>,
55    {
56        let file_path = path.as_ref();
57        let mut option = OpenOptions::new();
58        option.read(true).create(true).append(true);
59
60        option.open(file_path).await
61    }
62}