1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#![cfg_attr(feature = "nightly", deny(missing_docs))]
#![cfg_attr(feature = "nightly", feature(external_doc))]
#![cfg_attr(feature = "nightly", doc(include = "../README.md"))]
#![cfg_attr(test, deny(warnings))]
#[async_trait::async_trait]
pub trait RandomAccess {
type Error;
async fn write(
&mut self,
offset: u64,
data: &[u8],
) -> Result<(), Self::Error>;
async fn read(
&mut self,
offset: u64,
length: u64,
) -> Result<Vec<u8>, Self::Error>;
async fn read_to_writer(
&mut self,
offset: u64,
length: u64,
buf: &mut (impl futures_io::AsyncWrite + Send),
) -> Result<(), Self::Error>;
async fn del(&mut self, offset: u64, length: u64) -> Result<(), Self::Error>;
async fn truncate(&mut self, length: u64) -> Result<(), Self::Error>;
async fn len(&self) -> Result<u64, Self::Error>;
async fn is_empty(&mut self) -> Result<bool, Self::Error>;
async fn sync_all(&mut self) -> Result<(), Self::Error>;
}