diff --git a/icechunk/src/repo.rs b/icechunk/src/repo.rs index 41723b58..af1a4927 100644 --- a/icechunk/src/repo.rs +++ b/icechunk/src/repo.rs @@ -45,7 +45,7 @@ pub enum VersionInfo { } -#[derive(Debug)] +#[derive(Debug, Serialize, Deserialize)] pub struct Repository { config: RepositoryConfig, storage: Arc, diff --git a/icechunk/src/storage/virtual_ref.rs b/icechunk/src/storage/virtual_ref.rs index 78c2edbe..82a06c0f 100644 --- a/icechunk/src/storage/virtual_ref.rs +++ b/icechunk/src/storage/virtual_ref.rs @@ -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, @@ -28,8 +29,9 @@ pub enum ObjectStoreVirtualChunkResolverConfig { S3(S3ClientOptions), } -#[derive(Debug)] +#[derive(Debug, Serialize)] pub struct ObjectStoreVirtualChunkResolver { + #[serde(skip)] s3: OnceCell, config: Box>, } @@ -135,7 +137,17 @@ pub fn construct_valid_byte_range( impl private::Sealed for ObjectStoreVirtualChunkResolver {} +impl<'de> serde::Deserialize<'de> for ObjectStoreVirtualChunkResolver { + fn deserialize(deserializer: D) -> Result + 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,