Skip to main content

ArrayToArrayCodecTraits

Trait ArrayToArrayCodecTraits 

Source
pub trait ArrayToArrayCodecTraits: ArrayCodecTraits + Debug {
Show 13 methods // 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>, shape: &[NonZero<u64>], data_type: &DataType, fill_value: &FillValue, options: &CodecOptions, ) -> Result<ArrayBytes<'a>, CodecError>; fn decode<'a>( &self, bytes: ArrayBytes<'a>, shape: &[NonZero<u64>], data_type: &DataType, fill_value: &FillValue, options: &CodecOptions, ) -> Result<ArrayBytes<'a>, CodecError>; // Provided methods fn with_codec_specific_options( self: Arc<Self>, opts: &CodecSpecificOptions, ) -> Arc<dyn ArrayToArrayCodecTraits> { ... } fn encoded_fill_value( &self, decoded_data_type: &DataType, decoded_fill_value: &FillValue, ) -> Result<FillValue, CodecError> { ... } fn encoded_shape( &self, decoded_shape: &[NonZero<u64>], ) -> Result<Vec<NonZero<u64>>, CodecError> { ... } fn decoded_shape( &self, encoded_shape: &[NonZero<u64>], ) -> Result<Option<Vec<NonZero<u64>>>, CodecError> { ... } fn encoded_representation( &self, shape: &[NonZero<u64>], data_type: &DataType, fill_value: &FillValue, ) -> Result<(Vec<NonZero<u64>>, DataType, FillValue), CodecError> { ... } fn partial_decoder( self: Arc<Self>, input_handle: Arc<dyn ArrayPartialDecoderTraits>, shape: &[NonZero<u64>], data_type: &DataType, fill_value: &FillValue, options: &CodecOptions, ) -> Result<Arc<dyn ArrayPartialDecoderTraits>, CodecError> { ... } fn partial_encoder( self: Arc<Self>, input_output_handle: Arc<dyn ArrayPartialEncoderTraits>, shape: &[NonZero<u64>], data_type: &DataType, fill_value: &FillValue, options: &CodecOptions, ) -> Result<Arc<dyn ArrayPartialEncoderTraits>, CodecError> { ... } fn async_partial_decoder<'life0, 'life1, 'life2, 'life3, 'async_trait>( self: Arc<Self>, input_handle: Arc<dyn AsyncArrayPartialDecoderTraits>, shape: &'life0 [NonZero<u64>], data_type: &'life1 DataType, fill_value: &'life2 FillValue, options: &'life3 CodecOptions, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn AsyncArrayPartialDecoderTraits>, CodecError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, Self: Sync + Send + 'async_trait { ... } fn async_partial_encoder<'life0, 'life1, 'life2, 'life3, 'async_trait>( self: Arc<Self>, input_output_handle: Arc<dyn AsyncArrayPartialEncoderTraits>, shape: &'life0 [NonZero<u64>], data_type: &'life1 DataType, fill_value: &'life2 FillValue, options: &'life3 CodecOptions, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn AsyncArrayPartialEncoderTraits>, CodecError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, Self: Sync + Send + 'async_trait { ... }
}
Expand description

Traits for array to array codecs.

Required Methods§

Source

fn into_dyn(self: Arc<Self>) -> Arc<dyn ArrayToArrayCodecTraits>

Return a dynamic version of the codec.

Source

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.

Source

fn encode<'a>( &self, bytes: ArrayBytes<'a>, shape: &[NonZero<u64>], data_type: &DataType, fill_value: &FillValue, options: &CodecOptions, ) -> Result<ArrayBytes<'a>, CodecError>

Encode a chunk.

§Errors

Returns CodecError if a codec fails or bytes is incompatible with the decoded representation.

Source

fn decode<'a>( &self, bytes: ArrayBytes<'a>, shape: &[NonZero<u64>], data_type: &DataType, fill_value: &FillValue, options: &CodecOptions, ) -> Result<ArrayBytes<'a>, CodecError>

Decode a chunk.

§Errors

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

Provided Methods§

Source

fn with_codec_specific_options( self: Arc<Self>, opts: &CodecSpecificOptions, ) -> Arc<dyn ArrayToArrayCodecTraits>

Return a version of this codec reconfigured with the provided codec-specific options.

The default implementation returns the codec unchanged. Override this to read your codec’s options type from CodecSpecificOptions.

Source

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.

Source

fn encoded_shape( &self, decoded_shape: &[NonZero<u64>], ) -> Result<Vec<NonZero<u64>>, 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.

Source

fn decoded_shape( &self, encoded_shape: &[NonZero<u64>], ) -> Result<Option<Vec<NonZero<u64>>>, 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.

Source

fn encoded_representation( &self, shape: &[NonZero<u64>], data_type: &DataType, fill_value: &FillValue, ) -> Result<(Vec<NonZero<u64>>, DataType, FillValue), 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.

Source

fn partial_decoder( self: Arc<Self>, input_handle: Arc<dyn ArrayPartialDecoderTraits>, shape: &[NonZero<u64>], data_type: &DataType, fill_value: &FillValue, 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.

Source

fn partial_encoder( self: Arc<Self>, input_output_handle: Arc<dyn ArrayPartialEncoderTraits>, shape: &[NonZero<u64>], data_type: &DataType, fill_value: &FillValue, 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.

Source

fn async_partial_decoder<'life0, 'life1, 'life2, 'life3, 'async_trait>( self: Arc<Self>, input_handle: Arc<dyn AsyncArrayPartialDecoderTraits>, shape: &'life0 [NonZero<u64>], data_type: &'life1 DataType, fill_value: &'life2 FillValue, options: &'life3 CodecOptions, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn AsyncArrayPartialDecoderTraits>, CodecError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, Self: Sync + Send + 'async_trait,

Available on crate feature async only.

Initialise an asynchronous partial decoder.

The default implementation decodes the entire chunk.

§Errors

Returns a CodecError if initialisation fails.

Source

fn async_partial_encoder<'life0, 'life1, 'life2, 'life3, 'async_trait>( self: Arc<Self>, input_output_handle: Arc<dyn AsyncArrayPartialEncoderTraits>, shape: &'life0 [NonZero<u64>], data_type: &'life1 DataType, fill_value: &'life2 FillValue, options: &'life3 CodecOptions, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn AsyncArrayPartialEncoderTraits>, CodecError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, Self: Sync + Send + 'async_trait,

Available on crate feature async only.

Initialise an asynchronous partial encoder.

The default implementation reencodes the entire chunk.

§Errors

Returns a CodecError if initialisation fails.

Implementors§