Skip to content
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

Make CasObject serde::Serializable #172

Merged
merged 2 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"] }
5 changes: 3 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)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a thought, you may want to #[serde(skip)] the _buffer: [u8; 16] field.

/// Info struct for [CasObject]. This is stored at the end of the XORB.
pub struct CasObjectInfo {
/// CAS identifier: "XETBLOB"
Expand Down Expand Up @@ -247,7 +248,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