Struct zarrs::array::codec::array_to_bytes::codec_chain::CodecChain
source · pub struct CodecChain { /* private fields */ }
Expand description
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
.
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
true, or - preceding the first codec with
partial_decoder_should_cache_input
, whichever is further.
Implementations§
source§impl CodecChain
impl CodecChain
sourcepub fn new(
array_to_array: Vec<Box<dyn ArrayToArrayCodecTraits>>,
array_to_bytes: Box<dyn ArrayToBytesCodecTraits>,
bytes_to_bytes: Vec<Box<dyn BytesToBytesCodecTraits>>
) -> Self
pub fn new( array_to_array: Vec<Box<dyn ArrayToArrayCodecTraits>>, array_to_bytes: Box<dyn ArrayToBytesCodecTraits>, bytes_to_bytes: Vec<Box<dyn BytesToBytesCodecTraits>> ) -> Self
Create a new codec chain.
sourcepub fn from_metadata(metadatas: &[Metadata]) -> Result<Self, PluginCreateError>
pub fn from_metadata(metadatas: &[Metadata]) -> Result<Self, PluginCreateError>
Create a new codec chain from a list of metadata.
§Errors
Returns a PluginCreateError
if:
- a codec could not be created,
- no array to bytes codec is supplied, or
- more than one array to bytes codec is supplied.
sourcepub fn create_metadatas_opt(
&self,
options: &ArrayMetadataOptions
) -> Vec<Metadata>
pub fn create_metadatas_opt( &self, options: &ArrayMetadataOptions ) -> Vec<Metadata>
Create codec chain metadata.
sourcepub fn create_metadatas(&self) -> Vec<Metadata>
pub fn create_metadatas(&self) -> Vec<Metadata>
Create codec chain metadata with default options.
sourcepub fn array_to_array_codecs(&self) -> &[Box<dyn ArrayToArrayCodecTraits>]
pub fn array_to_array_codecs(&self) -> &[Box<dyn ArrayToArrayCodecTraits>]
Get the array to array codecs
sourcepub fn array_to_bytes_codec(&self) -> &Box<dyn ArrayToBytesCodecTraits>
pub fn array_to_bytes_codec(&self) -> &Box<dyn ArrayToBytesCodecTraits>
Get the array to bytes codec
sourcepub fn bytes_to_bytes_codecs(&self) -> &[Box<dyn BytesToBytesCodecTraits>]
pub fn bytes_to_bytes_codecs(&self) -> &[Box<dyn BytesToBytesCodecTraits>]
Get the bytes to bytes codecs
Trait Implementations§
source§impl ArrayCodecTraits for CodecChain
impl ArrayCodecTraits for CodecChain
source§fn recommended_concurrency(
&self,
decoded_representation: &ChunkRepresentation
) -> Result<RecommendedConcurrency, CodecError>
fn recommended_concurrency( &self, decoded_representation: &ChunkRepresentation ) -> Result<RecommendedConcurrency, CodecError>
source§fn encode(
&self,
decoded_value: Vec<u8>,
decoded_representation: &ChunkRepresentation,
options: &CodecOptions
) -> Result<Vec<u8>, CodecError>
fn encode( &self, decoded_value: Vec<u8>, decoded_representation: &ChunkRepresentation, options: &CodecOptions ) -> Result<Vec<u8>, CodecError>
source§fn decode(
&self,
encoded_value: Vec<u8>,
decoded_representation: &ChunkRepresentation,
options: &CodecOptions
) -> Result<Vec<u8>, CodecError>
fn decode( &self, encoded_value: Vec<u8>, decoded_representation: &ChunkRepresentation, options: &CodecOptions ) -> Result<Vec<u8>, CodecError>
source§fn decode_into_array_view(
&self,
encoded_value: &[u8],
decoded_representation: &ChunkRepresentation,
array_view: &ArrayView<'_>,
options: &CodecOptions
) -> Result<(), CodecError>
fn decode_into_array_view( &self, encoded_value: &[u8], decoded_representation: &ChunkRepresentation, array_view: &ArrayView<'_>, options: &CodecOptions ) -> Result<(), CodecError>
source§fn partial_decode_granularity(
&self,
decoded_representation: &ChunkRepresentation
) -> ChunkShape
fn partial_decode_granularity( &self, decoded_representation: &ChunkRepresentation ) -> ChunkShape
source§impl ArrayToBytesCodecTraits for CodecChain
impl ArrayToBytesCodecTraits for CodecChain
source§fn partial_decoder<'a>(
&'a self,
input_handle: Box<dyn BytesPartialDecoderTraits + 'a>,
decoded_representation: &ChunkRepresentation,
options: &CodecOptions
) -> Result<Box<dyn ArrayPartialDecoderTraits + 'a>, CodecError>
fn partial_decoder<'a>( &'a self, input_handle: Box<dyn BytesPartialDecoderTraits + 'a>, decoded_representation: &ChunkRepresentation, options: &CodecOptions ) -> Result<Box<dyn ArrayPartialDecoderTraits + 'a>, CodecError>
source§fn async_partial_decoder<'a, 'life0, 'life1, 'async_trait>(
&'a self,
input_handle: Box<dyn AsyncBytesPartialDecoderTraits + 'a>,
decoded_representation: &'life0 ChunkRepresentation,
options: &'life1 CodecOptions
) -> Pin<Box<dyn Future<Output = Result<Box<dyn AsyncArrayPartialDecoderTraits + 'a>, CodecError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn async_partial_decoder<'a, 'life0, 'life1, 'async_trait>(
&'a self,
input_handle: Box<dyn AsyncBytesPartialDecoderTraits + 'a>,
decoded_representation: &'life0 ChunkRepresentation,
options: &'life1 CodecOptions
) -> Pin<Box<dyn Future<Output = Result<Box<dyn AsyncArrayPartialDecoderTraits + 'a>, CodecError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
async
only.source§fn compute_encoded_size(
&self,
decoded_representation: &ChunkRepresentation
) -> Result<BytesRepresentation, CodecError>
fn compute_encoded_size( &self, decoded_representation: &ChunkRepresentation ) -> Result<BytesRepresentation, CodecError>
source§impl Clone for CodecChain
impl Clone for CodecChain
source§fn clone(&self) -> CodecChain
fn clone(&self) -> CodecChain
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl CodecTraits for CodecChain
impl CodecTraits for CodecChain
source§fn create_metadata_opt(
&self,
_options: &ArrayMetadataOptions
) -> Option<Metadata>
fn create_metadata_opt( &self, _options: &ArrayMetadataOptions ) -> Option<Metadata>
Returns None
since a codec chain does not have standard codec metadata.
Note that usage of the codec chain is explicit in Array
and CodecChain::create_metadatas_opt()
will call CodecTraits::create_metadata_opt()
from for each codec.
source§fn partial_decoder_should_cache_input(&self) -> bool
fn partial_decoder_should_cache_input(&self) -> bool
CodecChain
partial decoder.source§fn partial_decoder_decodes_all(&self) -> bool
fn partial_decoder_decodes_all(&self) -> bool
CodecChain
partial decoder.