Skip to content

Commit

Permalink
repo full serializable
Browse files Browse the repository at this point in the history
  • Loading branch information
mpiannucci committed Dec 10, 2024
1 parent 094f357 commit 91253dc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion icechunk/src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub enum VersionInfo {
}


#[derive(Debug)]
#[derive(Debug, Serialize, Deserialize)]
pub struct Repository {
config: RepositoryConfig,
storage: Arc<dyn Storage + Send + Sync>,
Expand Down
16 changes: 14 additions & 2 deletions icechunk/src/storage/virtual_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ use url::{self, Url};
use super::s3::{mk_client, range_to_header, S3ClientOptions};

#[async_trait]
pub trait VirtualChunkResolver: Debug + private::Sealed {
#[typetag::serde(tag = "type")]
pub trait VirtualChunkResolver: Debug + private::Sealed + Send + Sync {
async fn fetch_chunk(
&self,
location: &VirtualChunkLocation,
Expand All @@ -28,8 +29,9 @@ pub enum ObjectStoreVirtualChunkResolverConfig {
S3(S3ClientOptions),
}

#[derive(Debug)]
#[derive(Debug, Serialize)]
pub struct ObjectStoreVirtualChunkResolver {
#[serde(skip)]
s3: OnceCell<Client>,
config: Box<Option<ObjectStoreVirtualChunkResolverConfig>>,
}
Expand Down Expand Up @@ -135,7 +137,17 @@ pub fn construct_valid_byte_range(

impl private::Sealed for ObjectStoreVirtualChunkResolver {}

impl<'de> serde::Deserialize<'de> for ObjectStoreVirtualChunkResolver {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
Ok(Self::new(serde::Deserialize::deserialize(deserializer)?))
}
}

#[async_trait]
#[typetag::serde]
impl VirtualChunkResolver for ObjectStoreVirtualChunkResolver {
async fn fetch_chunk(
&self,
Expand Down

0 comments on commit 91253dc

Please sign in to comment.