From 2a4a848ca5f5ee20f1a7c2096d2e4df3834dc0d9 Mon Sep 17 00:00:00 2001 From: Lachlan Deakin Date: Mon, 23 Dec 2024 18:15:10 +1100 Subject: [PATCH] refactor: make `{Array,Bytes}PartialDecoderCache` private --- CHANGELOG.md | 1 + zarrs/src/array/codec.rs | 6 +++--- zarrs/src/array/codec/array_partial_decoder_cache.rs | 6 +++--- zarrs/src/array/codec/array_to_bytes/codec_chain.rs | 2 +- zarrs/src/array/codec/bytes_partial_decoder_cache.rs | 6 +++--- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ddbaa2b0..c1eb07b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Reduce metadata code duplication in the `Node` module +- **Breaking**: Make `{Array,Bytes}PartialDecoderCache` private ### Fixed - Cleanup unnecessary lifetime constraints in partial decoders diff --git a/zarrs/src/array/codec.rs b/zarrs/src/array/codec.rs index ce291d8e..9a67bcca 100644 --- a/zarrs/src/array/codec.rs +++ b/zarrs/src/array/codec.rs @@ -6,7 +6,7 @@ //! //! A [`CodecChain`] represents a codec sequence consisting of any number of array to array and bytes to bytes codecs, and one array to bytes codec. //! A codec chain is itself an array to bytes codec. -//! A [`ArrayPartialDecoderCache`] or [`BytesPartialDecoderCache`] may be inserted into a codec chain to optimise partial decoding where appropriate. +//! A cache may be inserted into a codec chain to optimise partial decoding where appropriate. //! //! See . @@ -59,8 +59,8 @@ use thiserror::Error; mod array_partial_decoder_cache; mod bytes_partial_decoder_cache; -pub use array_partial_decoder_cache::ArrayPartialDecoderCache; -pub use bytes_partial_decoder_cache::BytesPartialDecoderCache; +pub(crate) use array_partial_decoder_cache::ArrayPartialDecoderCache; +pub(crate) use bytes_partial_decoder_cache::BytesPartialDecoderCache; mod byte_interval_partial_decoder; pub use byte_interval_partial_decoder::ByteIntervalPartialDecoder; diff --git a/zarrs/src/array/codec/array_partial_decoder_cache.rs b/zarrs/src/array/codec/array_partial_decoder_cache.rs index fc706bb0..d3545204 100644 --- a/zarrs/src/array/codec/array_partial_decoder_cache.rs +++ b/zarrs/src/array/codec/array_partial_decoder_cache.rs @@ -8,7 +8,7 @@ use super::{ArrayPartialDecoderTraits, ArraySubset, CodecError, CodecOptions}; use super::AsyncArrayPartialDecoderTraits; /// A cache for an [`ArrayPartialDecoderTraits`] partial decoder. -pub struct ArrayPartialDecoderCache { +pub(crate) struct ArrayPartialDecoderCache { decoded_representation: ChunkRepresentation, cache: ArrayBytes<'static>, } @@ -18,7 +18,7 @@ impl ArrayPartialDecoderCache { /// /// # Errors /// Returns a [`CodecError`] if initialisation of the partial decoder fails. - pub fn new( + pub(crate) fn new( input_handle: &dyn ArrayPartialDecoderTraits, decoded_representation: ChunkRepresentation, options: &CodecOptions, @@ -43,7 +43,7 @@ impl ArrayPartialDecoderCache { /// /// # Errors /// Returns a [`CodecError`] if initialisation of the partial decoder fails. - pub async fn async_new( + pub(crate) async fn async_new( input_handle: &dyn AsyncArrayPartialDecoderTraits, decoded_representation: ChunkRepresentation, options: &CodecOptions, diff --git a/zarrs/src/array/codec/array_to_bytes/codec_chain.rs b/zarrs/src/array/codec/array_to_bytes/codec_chain.rs index 3a0678b8..2b41fe63 100644 --- a/zarrs/src/array/codec/array_to_bytes/codec_chain.rs +++ b/zarrs/src/array/codec/array_to_bytes/codec_chain.rs @@ -27,7 +27,7 @@ use crate::array::codec::{AsyncArrayPartialDecoderTraits, AsyncBytesPartialDecod /// A codec chain is a sequence of array to array, a bytes to bytes, and a sequence of array to bytes codecs. /// -/// A codec chain partial decoder may insert a cache: [`ArrayPartialDecoderCache`] or [`BytesPartialDecoderCache`]. +/// A codec chain partial decoder may insert a cache. /// For example, the output of the `blosc`/`gzip` codecs should be cached since they read and decode an entire chunk. /// If decoding (i.e. going backwards through a codec chain), then a cache may be inserted /// - following the last codec with [`partial_decoder_decodes_all`](crate::array::codec::CodecTraits::partial_decoder_decodes_all) true, or diff --git a/zarrs/src/array/codec/bytes_partial_decoder_cache.rs b/zarrs/src/array/codec/bytes_partial_decoder_cache.rs index 634866ea..d3d6cc77 100644 --- a/zarrs/src/array/codec/bytes_partial_decoder_cache.rs +++ b/zarrs/src/array/codec/bytes_partial_decoder_cache.rs @@ -13,7 +13,7 @@ use super::{BytesPartialDecoderTraits, CodecError, CodecOptions}; use super::AsyncBytesPartialDecoderTraits; /// A cache for a [`BytesPartialDecoderTraits`] partial decoder. -pub struct BytesPartialDecoderCache<'a> { +pub(crate) struct BytesPartialDecoderCache<'a> { cache: Option>, phantom: PhantomData<&'a ()>, } @@ -23,7 +23,7 @@ impl<'a> BytesPartialDecoderCache<'a> { /// /// # Errors /// Returns a [`CodecError`] if caching fails. - pub fn new( + pub(crate) fn new( input_handle: &dyn BytesPartialDecoderTraits, options: &CodecOptions, ) -> Result { @@ -41,7 +41,7 @@ impl<'a> BytesPartialDecoderCache<'a> { /// /// # Errors /// Returns a [`CodecError`] if caching fails. - pub async fn async_new( + pub(crate) async fn async_new( input_handle: &dyn AsyncBytesPartialDecoderTraits, options: &CodecOptions, ) -> Result, CodecError> {