Skip to content

Commit

Permalink
WIP on state encoding and storage
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronc committed Sep 30, 2024
1 parent e225188 commit 97a327b
Show file tree
Hide file tree
Showing 12 changed files with 110 additions and 410 deletions.
2 changes: 2 additions & 0 deletions rust/schema/src/binary/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ impl Codec for NativeBinaryCodec {
}

impl NativeBinaryCodec {
/// Encode an object value.
pub fn encode_object_value<'a, V: ObjectValue, F: WriterFactory>(value: V::In<'a>, writer_factory: &F) -> Result<F::Output, EncodeError> {
todo!()
}

/// Decode an object value.
pub fn decode_object_value<'a, V: ObjectValue>(input: &'a [u8], memory_manager: &'a MemoryManager) -> Result<V::Out<'a>, DecodeError> {
todo!()
}
Expand Down
8 changes: 6 additions & 2 deletions rust/schema/src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,13 @@ impl<'a> Writer for ReverseSliceWriter<'a> {
}
}

/// A buffer reader.
pub trait Reader<'a> {
/// Read a slice of bytes from the buffer and update the remaining length.
fn read_bytes(&mut self, size: usize) -> Result<&'a [u8], DecodeError>;
fn done(&self) -> Result<(), DecodeError>;

/// Check if the buffer has been completely read and return an error if not.
fn is_done(&self) -> Result<(), DecodeError>;
}

impl <'a> Reader<'a> for &'a [u8] {
Expand All @@ -83,7 +87,7 @@ impl <'a> Reader<'a> for &'a [u8] {
Ok(bz)
}

fn done(&self) -> Result<(), DecodeError> {
fn is_done(&self) -> Result<(), DecodeError> {
if !self.is_empty() {
return Err(DecodeError::InvalidData);
}
Expand Down
1 change: 0 additions & 1 deletion rust/schema/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ mod fields;
pub mod buffer;
pub mod mem;
mod mem2;
mod stateobject;

pub use structs::{StructCodec};
pub use r#enum::{EnumCodec};
Expand Down
Loading

0 comments on commit 97a327b

Please sign in to comment.