1use std::ops::{Deref, DerefMut};
2
3#[derive(Debug, Clone)]
7pub struct Page {
8 offset: usize,
11 buffer: Vec<u8>,
15}
16
17impl Page {
18 pub fn new(index: usize, buf: Vec<u8>) -> Self {
20 Page {
21 offset: index * buf.capacity(),
22 buffer: buf,
23 }
24 }
25
26 pub fn offset(&self) -> usize {
29 self.offset
30 }
31}
32
33impl Deref for Page {
34 type Target = [u8];
35 fn deref(&self) -> &Self::Target {
36 &self.buffer
37 }
38}
39
40impl DerefMut for Page {
41 fn deref_mut(&mut self) -> &mut Self::Target {
42 &mut self.buffer
43 }
44}