Trait ArrayToBytesCodecTraits

Source
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§

Source

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

Return a dynamic version of the codec.

Source

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.

Source

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.

Source

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§

Source

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,

Source

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.

Source

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.

Source

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,

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, '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,

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§