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
use std::ops::{Deref, DerefMut};
#[derive(Debug, Eq, Ord, PartialEq, PartialOrd, Clone)]
pub struct PartialNode {
pub parent: usize,
pub(crate) data: Option<Vec<u8>>,
pub(crate) length: usize,
pub(crate) index: usize,
}
impl PartialNode {
pub fn len(&self) -> usize {
self.length
}
pub fn is_empty(&self) -> bool {
self.length == 0
}
pub fn index(&self) -> usize {
self.index
}
pub fn data(&self) -> &Option<Vec<u8>> {
&self.data
}
}
impl Deref for PartialNode {
type Target = Option<Vec<u8>>;
fn deref(&self) -> &Self::Target {
&self.data
}
}
impl DerefMut for PartialNode {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.data
}
}