-
Notifications
You must be signed in to change notification settings - Fork 0
/
page.rs
53 lines (42 loc) · 995 Bytes
/
page.rs
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
53
use std::usize;
use crate::config::*;
pub struct Page {
page_id: Option<PageId>,
data: Data,
is_dirty: bool,
pin_count: usize,
}
impl Page {
pub fn new(page_id: Option<PageId>) -> Page {
Page {
page_id,
data: [0; PAGE_SIZE],
is_dirty: false,
pin_count: 0,
}
}
pub fn get_page_id(&self) -> Option<PageId> {
self.page_id
}
pub fn set_page_id(&mut self, page_id: PageId) {
self.page_id = Some(page_id);
}
pub fn get_data(&mut self) -> &mut Data {
&mut self.data
}
pub fn is_dirty(&self) -> bool {
self.is_dirty
}
pub fn set_dirty(&mut self, is_dirty: bool) {
self.is_dirty = is_dirty;
}
pub fn get_pin_count(&self) -> usize {
self.pin_count
}
pub fn increment_pin_count(&mut self) {
self.pin_count += 1;
}
pub fn decrement_pin_count(&mut self) {
self.pin_count -= 1;
}
}