-
Notifications
You must be signed in to change notification settings - Fork 0
Chunk Serialization #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
let mut vec = Vec::<BlockId>::new(); | ||
|
||
bytes.iter().for_each(|byte| { | ||
let symbol_bytes = &byte[0..4]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Todo: Reduce token size
Todo: Handle large tokens (> 4 Bits)
vec.push(symbol); | ||
} | ||
|
||
i += 3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Magic number
let mut i = 0; | ||
while i < bytes.len() { | ||
let symbol = bytes[i]; | ||
let count_bytes = &bytes[i + 1..i + 3]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Magic number
RedTerracotta, | ||
Terracotta, | ||
YellowTerracotta, | ||
macro_rules! enum_from_u8 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't plan on learning macros just yet, so this generated stuff is way beyond my understanding but it keeps the enum definition clear. 🪄
} | ||
} | ||
|
||
impl<'de> Deserialize<'de> for Chunk { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inspired by the deserialization docs:
https://serde.rs/impl-serializer.html
|
||
let mut bytes = Vec::<u8>::new(); | ||
tokens.iter().for_each(|token| { | ||
let symbol_bytes = token.symbol.to_le_bytes(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
le := little endian
Implement RLE of integer buffers for more efficient data transfer once client/server is rearchitectured.
Inspired by INCO Praktikum @ ZHAW.