pub trait ArrayToBytesCodecTraits: ArrayCodecTraits + Debug {
// Required methods
fn into_dyn(self: Arc<Self>) -> Arc<dyn ArrayToBytesCodecTraits>;
fn encoded_representation(
&self,
shape: &[NonZero<u64>],
data_type: &DataType,
fill_value: &FillValue,
) -> Result<BytesRepresentation, CodecError>;
fn encode<'a>(
&self,
bytes: ArrayBytes<'a>,
shape: &[NonZero<u64>],
data_type: &DataType,
fill_value: &FillValue,
options: &CodecOptions,
) -> Result<Cow<'a, [u8]>, CodecError>;
fn decode<'a>(
&self,
bytes: Cow<'a, [u8]>,
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 ArrayToBytesCodecTraits> { ... }
fn compact<'a>(
&self,
bytes: Cow<'a, [u8]>,
shape: &[NonZero<u64>],
data_type: &DataType,
fill_value: &FillValue,
options: &CodecOptions,
) -> Result<Option<Cow<'a, [u8]>>, CodecError> { ... }
fn decode_into(
&self,
bytes: Cow<'_, [u8]>,
shape: &[NonZero<u64>],
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: &[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 BytesPartialEncoderTraits>,
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 AsyncBytesPartialDecoderTraits>,
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 AsyncBytesPartialEncoderTraits>,
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 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: &[NonZero<u64>],
data_type: &DataType,
fill_value: &FillValue,
) -> Result<BytesRepresentation, CodecError>
fn encoded_representation( &self, shape: &[NonZero<u64>], 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: &[NonZero<u64>],
data_type: &DataType,
fill_value: &FillValue,
options: &CodecOptions,
) -> Result<Cow<'a, [u8]>, CodecError>
fn encode<'a>( &self, bytes: ArrayBytes<'a>, shape: &[NonZero<u64>], data_type: &DataType, fill_value: &FillValue, options: &CodecOptions, ) -> Result<Cow<'a, [u8]>, CodecError>
Encode a chunk.
§Errors
Returns CodecError if a codec fails or bytes is incompatible with the decoded representation.
Sourcefn decode<'a>(
&self,
bytes: Cow<'a, [u8]>,
shape: &[NonZero<u64>],
data_type: &DataType,
fill_value: &FillValue,
options: &CodecOptions,
) -> Result<ArrayBytes<'a>, CodecError>
fn decode<'a>( &self, bytes: Cow<'a, [u8]>, 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§
Sourcefn with_codec_specific_options(
self: Arc<Self>,
opts: &CodecSpecificOptions,
) -> Arc<dyn ArrayToBytesCodecTraits>
fn with_codec_specific_options( self: Arc<Self>, opts: &CodecSpecificOptions, ) -> Arc<dyn ArrayToBytesCodecTraits>
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.
Sourcefn compact<'a>(
&self,
bytes: Cow<'a, [u8]>,
shape: &[NonZero<u64>],
data_type: &DataType,
fill_value: &FillValue,
options: &CodecOptions,
) -> Result<Option<Cow<'a, [u8]>>, CodecError>
fn compact<'a>( &self, bytes: Cow<'a, [u8]>, shape: &[NonZero<u64>], data_type: &DataType, fill_value: &FillValue, options: &CodecOptions, ) -> Result<Option<Cow<'a, [u8]>>, 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: Cow<'_, [u8]>,
shape: &[NonZero<u64>],
data_type: &DataType,
fill_value: &FillValue,
output_target: ArrayBytesDecodeIntoTarget<'_>,
options: &CodecOptions,
) -> Result<(), CodecError>
fn decode_into( &self, bytes: Cow<'_, [u8]>, shape: &[NonZero<u64>], 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: &[NonZero<u64>],
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: &[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.
Sourcefn partial_encoder(
self: Arc<Self>,
input_output_handle: Arc<dyn BytesPartialEncoderTraits>,
shape: &[NonZero<u64>],
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: &[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.
Sourcefn async_partial_decoder<'life0, 'life1, 'life2, 'life3, 'async_trait>(
self: Arc<Self>,
input_handle: Arc<dyn AsyncBytesPartialDecoderTraits>,
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>>
Available on crate feature async only.
fn async_partial_decoder<'life0, 'life1, 'life2, 'life3, 'async_trait>( self: Arc<Self>, input_handle: Arc<dyn AsyncBytesPartialDecoderTraits>, 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>>
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<'life0, 'life1, 'life2, 'life3, 'async_trait>(
self: Arc<Self>,
input_output_handle: Arc<dyn AsyncBytesPartialEncoderTraits>,
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>>
Available on crate feature async only.
fn async_partial_encoder<'life0, 'life1, 'life2, 'life3, 'async_trait>( self: Arc<Self>, input_output_handle: Arc<dyn AsyncBytesPartialEncoderTraits>, 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>>
async only.Initialise an asynchronous partial encoder.
The default implementation reencodes the entire chunk.
§Errors
Returns a CodecError if initialisation fails.
Implementors§
impl ArrayToBytesCodecTraits for BytesCodec
impl ArrayToBytesCodecTraits for CodecChain
impl ArrayToBytesCodecTraits for OptionalCodec
impl ArrayToBytesCodecTraits for PackBitsCodec
impl ArrayToBytesCodecTraits for PcodecCodec
pcodec only.impl ArrayToBytesCodecTraits for ShardingCodec
sharding only.impl ArrayToBytesCodecTraits for VlenCodec
impl ArrayToBytesCodecTraits for VlenArrayCodec
impl ArrayToBytesCodecTraits for VlenBytesCodec
impl ArrayToBytesCodecTraits for VlenUtf8Codec
impl ArrayToBytesCodecTraits for VlenV2Codec
impl ArrayToBytesCodecTraits for ZfpCodec
zfp only.impl ArrayToBytesCodecTraits for ZfpyCodec
zfp only.