pub trait BytesToBytesCodecTraits: CodecTraits + Debug {
// Required methods
fn into_dyn(self: Arc<Self>) -> Arc<dyn BytesToBytesCodecTraits>;
fn recommended_concurrency(
&self,
decoded_representation: &BytesRepresentation,
) -> Result<RecommendedConcurrency, CodecError>;
fn encoded_representation(
&self,
decoded_representation: &BytesRepresentation,
) -> BytesRepresentation;
fn encode<'a>(
&self,
decoded_value: ArrayBytesRaw<'a>,
options: &CodecOptions,
) -> Result<ArrayBytesRaw<'a>, CodecError>;
fn decode<'a>(
&self,
encoded_value: ArrayBytesRaw<'a>,
decoded_representation: &BytesRepresentation,
options: &CodecOptions,
) -> Result<ArrayBytesRaw<'a>, CodecError>;
// Provided methods
fn with_codec_specific_options(
self: Arc<Self>,
opts: &CodecSpecificOptions,
) -> Arc<dyn BytesToBytesCodecTraits> { ... }
fn partial_decoder(
self: Arc<Self>,
input_handle: Arc<dyn BytesPartialDecoderTraits>,
decoded_representation: &BytesRepresentation,
options: &CodecOptions,
) -> Result<Arc<dyn BytesPartialDecoderTraits>, CodecError> { ... }
fn partial_encoder(
self: Arc<Self>,
input_output_handle: Arc<dyn BytesPartialEncoderTraits>,
decoded_representation: &BytesRepresentation,
options: &CodecOptions,
) -> Result<Arc<dyn BytesPartialEncoderTraits>, CodecError> { ... }
}Expand description
Traits for bytes to bytes codecs.
Required Methods§
Sourcefn into_dyn(self: Arc<Self>) -> Arc<dyn BytesToBytesCodecTraits>
fn into_dyn(self: Arc<Self>) -> Arc<dyn BytesToBytesCodecTraits>
Return a dynamic version of the codec.
Sourcefn recommended_concurrency(
&self,
decoded_representation: &BytesRepresentation,
) -> Result<RecommendedConcurrency, CodecError>
fn recommended_concurrency( &self, decoded_representation: &BytesRepresentation, ) -> Result<RecommendedConcurrency, CodecError>
Return the maximum internal concurrency supported for the requested decoded representation.
§Errors
Returns CodecError if the decoded representation is not valid for the codec.
Sourcefn encoded_representation(
&self,
decoded_representation: &BytesRepresentation,
) -> BytesRepresentation
fn encoded_representation( &self, decoded_representation: &BytesRepresentation, ) -> BytesRepresentation
Returns the size of the encoded representation given a size of the decoded representation.
Sourcefn encode<'a>(
&self,
decoded_value: ArrayBytesRaw<'a>,
options: &CodecOptions,
) -> Result<ArrayBytesRaw<'a>, CodecError>
fn encode<'a>( &self, decoded_value: ArrayBytesRaw<'a>, options: &CodecOptions, ) -> Result<ArrayBytesRaw<'a>, CodecError>
Sourcefn decode<'a>(
&self,
encoded_value: ArrayBytesRaw<'a>,
decoded_representation: &BytesRepresentation,
options: &CodecOptions,
) -> Result<ArrayBytesRaw<'a>, CodecError>
fn decode<'a>( &self, encoded_value: ArrayBytesRaw<'a>, decoded_representation: &BytesRepresentation, options: &CodecOptions, ) -> Result<ArrayBytesRaw<'a>, CodecError>
Provided Methods§
Sourcefn with_codec_specific_options(
self: Arc<Self>,
opts: &CodecSpecificOptions,
) -> Arc<dyn BytesToBytesCodecTraits>
fn with_codec_specific_options( self: Arc<Self>, opts: &CodecSpecificOptions, ) -> Arc<dyn BytesToBytesCodecTraits>
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 partial_decoder(
self: Arc<Self>,
input_handle: Arc<dyn BytesPartialDecoderTraits>,
decoded_representation: &BytesRepresentation,
options: &CodecOptions,
) -> Result<Arc<dyn BytesPartialDecoderTraits>, CodecError>
fn partial_decoder( self: Arc<Self>, input_handle: Arc<dyn BytesPartialDecoderTraits>, decoded_representation: &BytesRepresentation, options: &CodecOptions, ) -> Result<Arc<dyn BytesPartialDecoderTraits>, CodecError>
Initialises 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>,
decoded_representation: &BytesRepresentation,
options: &CodecOptions,
) -> Result<Arc<dyn BytesPartialEncoderTraits>, CodecError>
fn partial_encoder( self: Arc<Self>, input_output_handle: Arc<dyn BytesPartialEncoderTraits>, decoded_representation: &BytesRepresentation, options: &CodecOptions, ) -> Result<Arc<dyn BytesPartialEncoderTraits>, CodecError>
Initialise a partial encoder.
The default implementation reencodes the entire chunk.
§Errors
Returns a CodecError if initialisation fails.