pub trait ArrayToBytesCodecTraits: ArrayCodecTraits + Debug {
// Required methods
fn into_dyn(self: Arc<Self>) -> Arc<dyn ArrayToBytesCodecTraits>;
fn encoded_representation(
&self,
decoded_representation: &ChunkRepresentation,
) -> Result<BytesRepresentation, CodecError>;
fn encode<'a>(
&self,
bytes: ArrayBytes<'a>,
decoded_representation: &ChunkRepresentation,
options: &CodecOptions,
) -> Result<RawBytes<'a>, CodecError>;
fn decode<'a>(
&self,
bytes: RawBytes<'a>,
decoded_representation: &ChunkRepresentation,
options: &CodecOptions,
) -> Result<ArrayBytes<'a>, CodecError>;
// Provided methods
fn decode_into(
&self,
bytes: RawBytes<'_>,
decoded_representation: &ChunkRepresentation,
output_view: &mut ArrayBytesFixedDisjointView<'_>,
options: &CodecOptions,
) -> Result<(), CodecError> { ... }
fn partial_decoder(
self: Arc<Self>,
input_handle: Arc<dyn BytesPartialDecoderTraits>,
decoded_representation: &ChunkRepresentation,
options: &CodecOptions,
) -> Result<Arc<dyn ArrayPartialDecoderTraits>, CodecError> { ... }
fn partial_encoder(
self: Arc<Self>,
input_handle: Arc<dyn BytesPartialDecoderTraits>,
output_handle: Arc<dyn BytesPartialEncoderTraits>,
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 AsyncBytesPartialDecoderTraits>,
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<'life0, 'life1, 'async_trait>(
self: Arc<Self>,
input_handle: Arc<dyn AsyncBytesPartialDecoderTraits>,
output_handle: Arc<dyn AsyncBytesPartialEncoderTraits>,
decoded_representation: &'life0 ChunkRepresentation,
options: &'life1 CodecOptions,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn AsyncArrayPartialEncoderTraits>, CodecError>> + Send + 'async_trait>>
where Self: Sync + Send + 'async_trait,
'life0: 'async_trait,
'life1: '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,
decoded_representation: &ChunkRepresentation,
) -> Result<BytesRepresentation, CodecError>
fn encoded_representation( &self, decoded_representation: &ChunkRepresentation, ) -> 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>,
decoded_representation: &ChunkRepresentation,
options: &CodecOptions,
) -> Result<RawBytes<'a>, CodecError>
fn encode<'a>( &self, bytes: ArrayBytes<'a>, decoded_representation: &ChunkRepresentation, options: &CodecOptions, ) -> Result<RawBytes<'a>, CodecError>
Encode a chunk.
§Errors
Returns CodecError
if a codec fails or bytes
is incompatible with decoded_representation
.
Sourcefn decode<'a>(
&self,
bytes: RawBytes<'a>,
decoded_representation: &ChunkRepresentation,
options: &CodecOptions,
) -> Result<ArrayBytes<'a>, CodecError>
fn decode<'a>( &self, bytes: RawBytes<'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 decode_into(
&self,
bytes: RawBytes<'_>,
decoded_representation: &ChunkRepresentation,
output_view: &mut ArrayBytesFixedDisjointView<'_>,
options: &CodecOptions,
) -> Result<(), CodecError>
fn decode_into( &self, bytes: RawBytes<'_>, decoded_representation: &ChunkRepresentation, output_view: &mut ArrayBytesFixedDisjointView<'_>, options: &CodecOptions, ) -> Result<(), CodecError>
Decode into a subset of a preallocated output.
This method is intended for internal use by Array. It currently only works for fixed length data types.
The decoded representation shape and dimensionality does not need to match output_subset
, but the number of elements must match.
Chunk elements are written to the subset of the output in C order.
§Errors
Returns CodecError
if a codec fails or the number of elements in decoded_representation
does not match the number of elements in output_view
,
Sourcefn partial_decoder(
self: Arc<Self>,
input_handle: Arc<dyn BytesPartialDecoderTraits>,
decoded_representation: &ChunkRepresentation,
options: &CodecOptions,
) -> Result<Arc<dyn ArrayPartialDecoderTraits>, CodecError>
fn partial_decoder( self: Arc<Self>, input_handle: Arc<dyn BytesPartialDecoderTraits>, 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 BytesPartialDecoderTraits>,
output_handle: Arc<dyn BytesPartialEncoderTraits>,
decoded_representation: &ChunkRepresentation,
options: &CodecOptions,
) -> Result<Arc<dyn ArrayPartialEncoderTraits>, CodecError>
fn partial_encoder( self: Arc<Self>, input_handle: Arc<dyn BytesPartialDecoderTraits>, output_handle: Arc<dyn BytesPartialEncoderTraits>, 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 AsyncBytesPartialDecoderTraits>,
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 AsyncBytesPartialDecoderTraits>, 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<'life0, 'life1, 'async_trait>(
self: Arc<Self>,
input_handle: Arc<dyn AsyncBytesPartialDecoderTraits>,
output_handle: Arc<dyn AsyncBytesPartialEncoderTraits>,
decoded_representation: &'life0 ChunkRepresentation,
options: &'life1 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, 'async_trait>( self: Arc<Self>, input_handle: Arc<dyn AsyncBytesPartialDecoderTraits>, output_handle: Arc<dyn AsyncBytesPartialEncoderTraits>, decoded_representation: &'life0 ChunkRepresentation, options: &'life1 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 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.