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
#![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))]
use std::io;
pub trait RandomAccess {
  type Error;
  fn write(&mut self, offset: usize, data: &[u8]) -> Result<(), Self::Error>;
  fn read(
    &mut self,
    offset: usize,
    length: usize,
  ) -> Result<Vec<u8>, Self::Error>;
  fn read_to_writer(
    &mut self,
    offset: usize,
    length: usize,
    buf: &mut impl io::Write,
  ) -> Result<(), Self::Error>;
  fn del(&mut self, offset: usize, length: usize) -> Result<(), Self::Error>;
  fn truncate(&mut self, length: usize) -> Result<(), Self::Error>;
}