-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage.rs
More file actions
36 lines (29 loc) Β· 686 Bytes
/
page.rs
File metadata and controls
36 lines (29 loc) Β· 686 Bytes
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
use pyo3::prelude::*;
static MAX_SIZE_RECORD: u64 = 512;
#[pyclass]
#[derive(Clone, Debug)]
pub struct PhysicalPage {
pub data: [u64; 512],
pub num_records: u64,
}
impl PhysicalPage {
// Init
pub fn new() -> Self {
PhysicalPage {
data: [0u64; 512],
num_records: 0,
}
}
pub fn has_capacity(&self) -> bool {
return self.num_records < MAX_SIZE_RECORD;
}
pub fn write(&mut self, value: u64) {
self.data[self.num_records as usize] = value;
self.num_records += 1;
}
pub fn read(&self, index: usize) -> Option<u64> {
Some(self.data[index])
}
}
#[cfg(test)]
mod tests {}