Trait zarrs::array::codec::ArrayCodecTraits

source ·
pub trait ArrayCodecTraits: CodecTraits {
    // Required methods
    fn recommended_concurrency(
        &self,
        decoded_representation: &ChunkRepresentation
    ) -> Result<RecommendedConcurrency, CodecError>;
    fn encode(
        &self,
        decoded_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>;

    // Provided methods
    fn decode_into_array_view(
        &self,
        encoded_value: &[u8],
        decoded_representation: &ChunkRepresentation,
        array_view: &ArrayView<'_>,
        options: &CodecOptions
    ) -> Result<(), CodecError> { ... }
    fn partial_decode_granularity(
        &self,
        decoded_representation: &ChunkRepresentation
    ) -> ChunkShape { ... }
}
Expand description

Traits for both array to array and array to bytes codecs.

Required Methods§

source

fn recommended_concurrency( &self, decoded_representation: &ChunkRepresentation ) -> Result<RecommendedConcurrency, CodecError>

Return the recommended concurrency for the requested decoded representation.

§Errors

Returns CodecError if the decoded representation is not valid for the codec.

source

fn encode( &self, decoded_value: Vec<u8>, decoded_representation: &ChunkRepresentation, options: &CodecOptions ) -> Result<Vec<u8>, CodecError>

Encode a chunk.

§Errors

Returns CodecError if a codec fails or decoded_value is incompatible with decoded_representation.

source

fn decode( &self, encoded_value: Vec<u8>, decoded_representation: &ChunkRepresentation, options: &CodecOptions ) -> Result<Vec<u8>, CodecError>

Decode a chunk.

§Errors

Returns CodecError if a codec fails or the decoded output is incompatible with decoded_representation.

Provided Methods§

source

fn decode_into_array_view( &self, encoded_value: &[u8], decoded_representation: &ChunkRepresentation, array_view: &ArrayView<'_>, options: &CodecOptions ) -> Result<(), CodecError>

Decode into the subset of an array.

The default implementation decodes the chunk as normal then copies it into the array subset. Codecs can override this method to avoid allocations where possible.

§Errors

Returns an error if the internal call to decode fails.

source

fn partial_decode_granularity( &self, decoded_representation: &ChunkRepresentation ) -> ChunkShape

Return the partial decode granularity.

This represents the shape of the smallest subset of a chunk that can be efficiently decoded if the chunk were subdivided into a regular grid. For most codecs, this is just the shape of the chunk. It is the shape of the “inner chunks” for the sharding codec.

Implementors§

source§

impl ArrayCodecTraits for BitroundCodec

Available on crate feature bitround only.
source§

impl ArrayCodecTraits for TransposeCodec

Available on crate feature transpose only.
source§

impl ArrayCodecTraits for BytesCodec

source§

impl ArrayCodecTraits for CodecChain

source§

impl ArrayCodecTraits for PcodecCodec

Available on crate feature pcodec only.
source§

impl ArrayCodecTraits for ShardingCodec

Available on crate feature sharding only.
source§

impl ArrayCodecTraits for ZfpCodec

Available on crate feature zfp only.