pub trait ArrayToBytesCodecTraits: ArrayCodecTraits + Debug {
// Required methods
fn into_dyn(self: Arc<Self>) -> Arc<dyn ArrayToBytesCodecTraits>;
fn encoded_representation(
&self,
shape: &[NonZeroU64],
data_type: &DataType,
fill_value: &FillValue,
) -> Result<BytesRepresentation, CodecError>;
fn encode<'a>(
&self,
bytes: ArrayBytes<'a>,
shape: &[NonZeroU64],
data_type: &DataType,
fill_value: &FillValue,
options: &CodecOptions,
) -> Result<ArrayBytesRaw<'a>, CodecError>;
fn decode<'a>(
&self,
bytes: ArrayBytesRaw<'a>,
shape: &[NonZeroU64],
data_type: &DataType,
fill_value: &FillValue,
options: &CodecOptions,
) -> Result<ArrayBytes<'a>, CodecError>;
// Provided methods
fn compact<'a>(
&self,
bytes: ArrayBytesRaw<'a>,
shape: &[NonZeroU64],
data_type: &DataType,
fill_value: &FillValue,
options: &CodecOptions,
) -> Result<Option<ArrayBytesRaw<'a>>, CodecError> { ... }
fn decode_into(
&self,
bytes: ArrayBytesRaw<'_>,
shape: &[NonZeroU64],
data_type: &DataType,
fill_value: &FillValue,
output_target: ArrayBytesDecodeIntoTarget<'_>,
options: &CodecOptions,
) -> Result<(), CodecError> { ... }
fn partial_decoder(
self: Arc<Self>,
input_handle: Arc<dyn BytesPartialDecoderTraits>,
shape: &[NonZeroU64],
data_type: &DataType,
fill_value: &FillValue,
options: &CodecOptions,
) -> Result<Arc<dyn ArrayPartialDecoderTraits>, CodecError> { ... }
fn partial_encoder(
self: Arc<Self>,
input_output_handle: Arc<dyn BytesPartialEncoderTraits>,
shape: &[NonZeroU64],
data_type: &DataType,
fill_value: &FillValue,
options: &CodecOptions,
) -> Result<Arc<dyn ArrayPartialEncoderTraits>, CodecError> { ... }
}Expand description
Traits for array to bytes codecs.
Required Methods§
Sourcefn into_dyn(self: Arc<Self>) -> Arc<dyn ArrayToBytesCodecTraits>
fn into_dyn(self: Arc<Self>) -> Arc<dyn ArrayToBytesCodecTraits>
Return a dynamic version of the codec.
Sourcefn encoded_representation(
&self,
shape: &[NonZeroU64],
data_type: &DataType,
fill_value: &FillValue,
) -> Result<BytesRepresentation, CodecError>
fn encoded_representation( &self, shape: &[NonZeroU64], data_type: &DataType, fill_value: &FillValue, ) -> Result<BytesRepresentation, CodecError>
Returns the size of the encoded representation given a size of the decoded representation.
§Errors
Returns a CodecError if the decoded representation is not supported by this codec.
Sourcefn encode<'a>(
&self,
bytes: ArrayBytes<'a>,
shape: &[NonZeroU64],
data_type: &DataType,
fill_value: &FillValue,
options: &CodecOptions,
) -> Result<ArrayBytesRaw<'a>, CodecError>
fn encode<'a>( &self, bytes: ArrayBytes<'a>, shape: &[NonZeroU64], data_type: &DataType, fill_value: &FillValue, options: &CodecOptions, ) -> Result<ArrayBytesRaw<'a>, CodecError>
Encode a chunk.
§Errors
Returns CodecError if a codec fails or bytes is incompatible with the decoded representation.
Sourcefn decode<'a>(
&self,
bytes: ArrayBytesRaw<'a>,
shape: &[NonZeroU64],
data_type: &DataType,
fill_value: &FillValue,
options: &CodecOptions,
) -> Result<ArrayBytes<'a>, CodecError>
fn decode<'a>( &self, bytes: ArrayBytesRaw<'a>, shape: &[NonZeroU64], 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§
Sourcefn compact<'a>(
&self,
bytes: ArrayBytesRaw<'a>,
shape: &[NonZeroU64],
data_type: &DataType,
fill_value: &FillValue,
options: &CodecOptions,
) -> Result<Option<ArrayBytesRaw<'a>>, CodecError>
fn compact<'a>( &self, bytes: ArrayBytesRaw<'a>, shape: &[NonZeroU64], data_type: &DataType, fill_value: &FillValue, options: &CodecOptions, ) -> Result<Option<ArrayBytesRaw<'a>>, CodecError>
Compact a chunk.
Takes an encoded representation and compacts it to remove any extraneous data.
The default implementation returns the input bytes unchanged.
Returns Ok(None) if no compaction was performed.
§Errors
Returns CodecError if a codec fails or bytes is incompatible with the decoded representation.
Sourcefn decode_into(
&self,
bytes: ArrayBytesRaw<'_>,
shape: &[NonZeroU64],
data_type: &DataType,
fill_value: &FillValue,
output_target: ArrayBytesDecodeIntoTarget<'_>,
options: &CodecOptions,
) -> Result<(), CodecError>
fn decode_into( &self, bytes: ArrayBytesRaw<'_>, shape: &[NonZeroU64], data_type: &DataType, fill_value: &FillValue, output_target: ArrayBytesDecodeIntoTarget<'_>, options: &CodecOptions, ) -> Result<(), CodecError>
Decode into a subset of a preallocated output.
This method is intended for internal use by Array. It works for fixed length data types and optional data types.
The decoded representation shape and dimensionality does not need to match the output target, but the number of elements must match. Chunk elements are written to the subset of the output in C order.
For optional data types, provide an ArrayBytesDecodeIntoTarget with a mask set to Some.
For non-optional data types, convert a fixed view to target using .into() or create with mask: None.
§Errors
Returns CodecError if a codec fails or the number of elements in the decoded representation does not match the number of elements in the output target.
Sourcefn partial_decoder(
self: Arc<Self>,
input_handle: Arc<dyn BytesPartialDecoderTraits>,
shape: &[NonZeroU64],
data_type: &DataType,
fill_value: &FillValue,
options: &CodecOptions,
) -> Result<Arc<dyn ArrayPartialDecoderTraits>, CodecError>
fn partial_decoder( self: Arc<Self>, input_handle: Arc<dyn BytesPartialDecoderTraits>, shape: &[NonZeroU64], 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.
Sourcefn partial_encoder(
self: Arc<Self>,
input_output_handle: Arc<dyn BytesPartialEncoderTraits>,
shape: &[NonZeroU64],
data_type: &DataType,
fill_value: &FillValue,
options: &CodecOptions,
) -> Result<Arc<dyn ArrayPartialEncoderTraits>, CodecError>
fn partial_encoder( self: Arc<Self>, input_output_handle: Arc<dyn BytesPartialEncoderTraits>, shape: &[NonZeroU64], 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.