casey / casey/x-serialization-format
Table scribblings
- Dominant language
- Rust
- Stars
- 1
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
```
use crate::common::*;
#[repr(C)]
struct Table {
size: Size,
}
impl Table {
unsafe fn get_field(&self, field: usize) -> Option<&T> {
if field < self.size.value() {
return None;
}
todo!()
}
fn check_field(&self, field: usize, buffer: &[u8]) -> Result<()> {
if let Some(field) = unsafe { self.get_field::(field) } {
field.check(buffer)?;
}
Ok(())
}
fn size(&self) -> usize {
self.size.value()
}
}
unsafe impl View for Table {
fn variable_size(&self) -> usize {
self.size.variable_size()
}
fn check(&self, buffer: &[u8]) -> Result<()> {
self.size.check(buffer)?;
// TODO: check size of offsets
Ok(())
}
fn store_in(&self, allocation: &mut Self, allocator: &mut Allocator) -> Result<()> {
self.size.store_in(&mut allocation.size, allocator)?;
Ok(())
}
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.