Skip to content
Snippets Groups Projects
Verified Commit e2a8d9d7 authored by João Magalhães's avatar João Magalhães :rocket:
Browse files

chore: initial end block support

parent 5d9334c6
No related branches found
No related tags found
1 merge request!31System state save
Pipeline #3229 passed
......@@ -27,6 +27,7 @@ pub struct BeesState {
name: BeesName,
info: BeesInfo,
core: BeesCore,
end: BeesBlockHeader,
}
impl BeesState {
......@@ -61,6 +62,7 @@ impl Serialize for BeesState {
self.name.save(buffer);
self.info.save(buffer);
self.core.save(buffer);
self.end.save(buffer);
self.footer.save(buffer);
}
......@@ -74,9 +76,13 @@ impl Serialize for BeesState {
data.seek(SeekFrom::Start(self.footer.start_offset as u64))
.unwrap();
// @TODO we need to soft code this loading process to make it
// more flexible and able to handle a random sequence of blocks
// as we never know which blocks are we going to find
self.name.load(data);
self.info.load(data);
self.core.load(data);
self.end.load(data);
}
}
......@@ -87,6 +93,7 @@ impl State for BeesState {
name: BeesName::from_gb(gb),
info: BeesInfo::from_gb(gb),
core: BeesCore::from_gb(gb),
end: BeesBlockHeader::new(String::from("END "), 0),
}
}
......@@ -131,6 +138,12 @@ impl Serialize for BeesBlockHeader {
}
}
impl Default for BeesBlockHeader {
fn default() -> Self {
Self::new(String::from(" "), 0)
}
}
pub struct BeesBuffer {
size: u32,
offset: u32,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment