pub trait ArrayToArrayCodecTraits: ArrayCodecTraits + Debug {
// Required methods
fn into_dyn(self: Arc<Self>) -> Arc<dyn ArrayToArrayCodecTraits>;
fn encoded_data_type(
&self,
decoded_data_type: &DataType,
) -> Result<DataType, CodecError>;
fn encode<'a>(
&self,
bytes: ArrayBytes<'a>,
decoded_representation: &ChunkRepresentation,
options: &CodecOptions,
) -> Result<ArrayBytes<'a>, CodecError>;
fn decode<'a>(
&self,
bytes: ArrayBytes<'a>,
decoded_representation: &ChunkRepresentation,
options: &CodecOptions,
) -> Result<ArrayBytes<'a>, CodecError>;
// Provided methods
fn encoded_fill_value(
&self,
decoded_data_type: &DataType,
decoded_fill_value: &FillValue,
) -> Result<FillValue, CodecError> { ... }
fn encoded_shape(
&self,
decoded_shape: &[NonZeroU64],
) -> Result<ChunkShape, CodecError> { ... }
fn decoded_shape(
&self,
encoded_shape: &[NonZeroU64],
) -> Result<Option<ChunkShape>, CodecError> { ... }
fn encoded_representation(
&self,
decoded_representation: &ChunkRepresentation,
) -> Result<ChunkRepresentation, CodecError> { ... }
fn partial_decoder(
self: Arc<Self>,
input_handle: Arc<dyn ArrayPartialDecoderTraits>,
decoded_representation: &ChunkRepresentation,
options: &CodecOptions,
) -> Result<Arc<dyn ArrayPartialDecoderTraits>, CodecError> { ... }
fn partial_encoder(
self: Arc<Self>,
input_handle: Arc<dyn ArrayPartialDecoderTraits>,
output_handle: Arc<dyn ArrayPartialEncoderTraits>,
decoded_representation: &ChunkRepresentation,
options: &CodecOptions,
) -> Result<Arc<dyn ArrayPartialEncoderTraits>, CodecError> { ... }
fn async_partial_decoder<'life0, 'life1, 'async_trait>(
self: Arc<Self>,
input_handle: Arc<dyn AsyncArrayPartialDecoderTraits>,
decoded_representation: &'life0 ChunkRepresentation,
options: &'life1 CodecOptions,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn AsyncArrayPartialDecoderTraits>, CodecError>> + Send + 'async_trait>>
where Self: Sync + Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn async_partial_encoder(
self: Arc<Self>,
input_handle: Arc<dyn AsyncArrayPartialDecoderTraits>,
output_handle: Arc<dyn AsyncArrayPartialEncoderTraits>,
decoded_representation: &ChunkRepresentation,
options: &CodecOptions,
) -> Result<Arc<dyn AsyncArrayPartialEncoderTraits>, CodecError> { ... }
}
Expand description
Traits for array to array codecs.
Required Methods§
Sourcefn into_dyn(self: Arc<Self>) -> Arc<dyn ArrayToArrayCodecTraits>
fn into_dyn(self: Arc<Self>) -> Arc<dyn ArrayToArrayCodecTraits>
Return a dynamic version of the codec.
Sourcefn encoded_data_type(
&self,
decoded_data_type: &DataType,
) -> Result<DataType, CodecError>
fn encoded_data_type( &self, decoded_data_type: &DataType, ) -> Result<DataType, CodecError>
Returns the encoded data type for a given decoded data type.
§Errors
Returns a CodecError
if the data type is not supported by this codec.
Sourcefn encode<'a>(
&self,
bytes: ArrayBytes<'a>,
decoded_representation: &ChunkRepresentation,
options: &CodecOptions,
) -> Result<ArrayBytes<'a>, CodecError>
fn encode<'a>( &self, bytes: ArrayBytes<'a>, decoded_representation: &ChunkRepresentation, options: &CodecOptions, ) -> Result<ArrayBytes<'a>, CodecError>
Encode a chunk.
§Errors
Returns CodecError
if a codec fails or bytes
is incompatible with decoded_representation
.
Sourcefn decode<'a>(
&self,
bytes: ArrayBytes<'a>,
decoded_representation: &ChunkRepresentation,
options: &CodecOptions,
) -> Result<ArrayBytes<'a>, CodecError>
fn decode<'a>( &self, bytes: ArrayBytes<'a>, decoded_representation: &ChunkRepresentation, options: &CodecOptions, ) -> Result<ArrayBytes<'a>, CodecError>
Decode a chunk.
§Errors
Returns CodecError
if a codec fails or the decoded output is incompatible with decoded_representation
.
Provided Methods§
Sourcefn encoded_fill_value(
&self,
decoded_data_type: &DataType,
decoded_fill_value: &FillValue,
) -> Result<FillValue, CodecError>
fn encoded_fill_value( &self, decoded_data_type: &DataType, decoded_fill_value: &FillValue, ) -> Result<FillValue, CodecError>
Returns the encoded fill value for a given decoded fill value
The encoded fill value is computed by applying ArrayToArrayCodecTraits::encode
to the decoded_fill_value
.
This may need to be implemented manually if a codec does not support encoding a single element or the encoding is otherwise dependent on the chunk shape.
§Errors
Returns a CodecError
if the data type is not supported by this codec.
Sourcefn encoded_shape(
&self,
decoded_shape: &[NonZeroU64],
) -> Result<ChunkShape, CodecError>
fn encoded_shape( &self, decoded_shape: &[NonZeroU64], ) -> Result<ChunkShape, CodecError>
Returns the shape of the encoded chunk for a given decoded chunk shape.
The default implementation returns the shape unchanged.
§Errors
Returns a CodecError
if the shape is not supported by this codec.
Sourcefn decoded_shape(
&self,
encoded_shape: &[NonZeroU64],
) -> Result<Option<ChunkShape>, CodecError>
fn decoded_shape( &self, encoded_shape: &[NonZeroU64], ) -> Result<Option<ChunkShape>, CodecError>
Returns the shape of the decoded chunk for a given encoded chunk shape.
The default implementation returns the shape unchanged.
Returns None
if the decoded shape cannot be determined from the encoded shape.
§Errors
Returns a CodecError
if the shape is not supported by this codec.
Sourcefn encoded_representation(
&self,
decoded_representation: &ChunkRepresentation,
) -> Result<ChunkRepresentation, CodecError>
fn encoded_representation( &self, decoded_representation: &ChunkRepresentation, ) -> Result<ChunkRepresentation, CodecError>
Returns the encoded chunk representation given the decoded chunk representation.
The default implementation returns the chunk representation from the outputs of
§Errors
Returns a CodecError
if the decoded chunk representation is not supported by this codec.
Sourcefn partial_decoder(
self: Arc<Self>,
input_handle: Arc<dyn ArrayPartialDecoderTraits>,
decoded_representation: &ChunkRepresentation,
options: &CodecOptions,
) -> Result<Arc<dyn ArrayPartialDecoderTraits>, CodecError>
fn partial_decoder( self: Arc<Self>, input_handle: Arc<dyn ArrayPartialDecoderTraits>, decoded_representation: &ChunkRepresentation, options: &CodecOptions, ) -> Result<Arc<dyn ArrayPartialDecoderTraits>, CodecError>
Initialise a partial decoder.
The default implementation decodes the entire chunk.
§Errors
Returns a CodecError
if initialisation fails.
Sourcefn partial_encoder(
self: Arc<Self>,
input_handle: Arc<dyn ArrayPartialDecoderTraits>,
output_handle: Arc<dyn ArrayPartialEncoderTraits>,
decoded_representation: &ChunkRepresentation,
options: &CodecOptions,
) -> Result<Arc<dyn ArrayPartialEncoderTraits>, CodecError>
fn partial_encoder( self: Arc<Self>, input_handle: Arc<dyn ArrayPartialDecoderTraits>, output_handle: Arc<dyn ArrayPartialEncoderTraits>, decoded_representation: &ChunkRepresentation, options: &CodecOptions, ) -> Result<Arc<dyn ArrayPartialEncoderTraits>, CodecError>
Initialise a partial encoder.
The default implementation reencodes the entire chunk.
§Errors
Returns a CodecError
if initialisation fails.
Sourcefn async_partial_decoder<'life0, 'life1, 'async_trait>(
self: Arc<Self>,
input_handle: Arc<dyn AsyncArrayPartialDecoderTraits>,
decoded_representation: &'life0 ChunkRepresentation,
options: &'life1 CodecOptions,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn AsyncArrayPartialDecoderTraits>, CodecError>> + Send + 'async_trait>>
Available on crate feature async
only.
fn async_partial_decoder<'life0, 'life1, 'async_trait>( self: Arc<Self>, input_handle: Arc<dyn AsyncArrayPartialDecoderTraits>, decoded_representation: &'life0 ChunkRepresentation, options: &'life1 CodecOptions, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn AsyncArrayPartialDecoderTraits>, CodecError>> + Send + 'async_trait>>
async
only.Initialise an asynchronous partial decoder.
The default implementation decodes the entire chunk.
§Errors
Returns a CodecError
if initialisation fails.
Sourcefn async_partial_encoder(
self: Arc<Self>,
input_handle: Arc<dyn AsyncArrayPartialDecoderTraits>,
output_handle: Arc<dyn AsyncArrayPartialEncoderTraits>,
decoded_representation: &ChunkRepresentation,
options: &CodecOptions,
) -> Result<Arc<dyn AsyncArrayPartialEncoderTraits>, CodecError>
Available on crate feature async
only.
fn async_partial_encoder( self: Arc<Self>, input_handle: Arc<dyn AsyncArrayPartialDecoderTraits>, output_handle: Arc<dyn AsyncArrayPartialEncoderTraits>, decoded_representation: &ChunkRepresentation, options: &CodecOptions, ) -> Result<Arc<dyn AsyncArrayPartialEncoderTraits>, CodecError>
async
only.Initialise an asynchronous partial encoder.
The default implementation reencodes the entire chunk.
§Errors
Returns a CodecError
if initialisation fails.
Implementors§
impl ArrayToArrayCodecTraits for BitroundCodec
bitround
only.impl ArrayToArrayCodecTraits for FixedScaleOffsetCodec
impl ArrayToArrayCodecTraits for SqueezeCodec
impl ArrayToArrayCodecTraits for TransposeCodec
transpose
only.