Skip to content

Commit

Permalink
Make CasObject serde::Serializable (#172)
Browse files Browse the repository at this point in the history
See title -- should be self-explanatory.
  • Loading branch information
znation authored Feb 17, 2025
1 parent 54ff005 commit d06daff
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion cas_object/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ blake3 = "1.5.4"
futures = { version = "0.3.31" }
tokio-util = {version = "0.7.12", features = ["io"]}
tokio = {version = "1.41.1" }
half = "2.4.1"
half = "2.4.1"
serde = { version = "1.0.129", features = ["derive"] }
6 changes: 4 additions & 2 deletions cas_object/src/cas_object_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use futures::AsyncReadExt;
use merkledb::prelude::MerkleDBHighLevelMethodsV1;
use merkledb::{Chunk, MerkleMemDB};
use merklehash::{DataHash, MerkleHash};
use serde::Serialize;
use tracing::warn;

use crate::cas_chunk_format::{deserialize_chunk, serialize_chunk};
Expand All @@ -19,7 +20,7 @@ pub(crate) const CAS_OBJECT_FORMAT_IDENT: CasObjectIdent = [b'X', b'E', b'T', b'
pub(crate) const CAS_OBJECT_FORMAT_VERSION: u8 = 0;
const CAS_OBJECT_INFO_DEFAULT_LENGTH: u32 = 60;

#[derive(Clone, PartialEq, Eq, Debug)]
#[derive(Clone, PartialEq, Eq, Debug, Serialize)]
/// Info struct for [CasObject]. This is stored at the end of the XORB.
pub struct CasObjectInfo {
/// CAS identifier: "XETBLOB"
Expand Down Expand Up @@ -49,6 +50,7 @@ pub struct CasObjectInfo {
/// Merklehash for each chunk stored in the Xorb. Length of vector is num_chunks.
pub chunk_hashes: Vec<MerkleHash>,

#[serde(skip)]
/// Unused 16-byte buffer to allow for future extensibility.
_buffer: [u8; 16],
}
Expand Down Expand Up @@ -247,7 +249,7 @@ impl CasObjectInfo {
}
}

#[derive(Clone, PartialEq, Eq, Debug)]
#[derive(Clone, PartialEq, Eq, Debug, Serialize)]
/// XORB: 16MB data block for storing chunks.
///
/// Has Info footer, and a set of functions that interact directly with XORB.
Expand Down

0 comments on commit d06daff

Please sign in to comment.