Skip to main content

BytesPartialDecoderTraits

Trait BytesPartialDecoderTraits 

Source
pub trait BytesPartialDecoderTraits:
    Any
    + MaybeSend
    + MaybeSync {
    // Required methods
    fn exists(&self) -> Result<bool, StorageError>;
    fn size_held(&self) -> usize;
    fn partial_decode_many(
        &self,
        decoded_regions: ByteRangeIterator<'_>,
        options: &CodecOptions,
    ) -> Result<Option<Vec<ArrayBytesRaw<'_>>>, CodecError>;
    fn supports_partial_decode(&self) -> bool;

    // Provided methods
    fn partial_decode(
        &self,
        decoded_region: ByteRange,
        options: &CodecOptions,
    ) -> Result<Option<ArrayBytesRaw<'_>>, CodecError> { ... }
    fn decode(
        &self,
        options: &CodecOptions,
    ) -> Result<Option<ArrayBytesRaw<'_>>, CodecError> { ... }
}
Expand description

Partial bytes decoder traits.

Required Methods§

Source

fn exists(&self) -> Result<bool, StorageError>

Returns whether the chunk exists.

§Errors

Returns StorageError if a storage operation fails.

Source

fn size_held(&self) -> usize

Returns the size of chunk bytes held by the partial decoder.

Intended for use by size-constrained partial decoder caches.

Source

fn partial_decode_many( &self, decoded_regions: ByteRangeIterator<'_>, options: &CodecOptions, ) -> Result<Option<Vec<ArrayBytesRaw<'_>>>, CodecError>

Partially decode byte ranges.

Returns None if partial decoding of the input handle returns None.

§Errors

Returns CodecError if a codec fails or a byte range is invalid.

Source

fn supports_partial_decode(&self) -> bool

Returns whether this decoder supports partial decoding.

If this returns true, the decoder can efficiently handle partial decoding operations. If this returns false, partial decoding will fall back to a full decode operation.

Provided Methods§

Source

fn partial_decode( &self, decoded_region: ByteRange, options: &CodecOptions, ) -> Result<Option<ArrayBytesRaw<'_>>, CodecError>

Partially decode a byte range.

Returns None if partial decoding of the input handle returns None.

§Errors

Returns CodecError if a codec fails or the byte range is invalid.

Source

fn decode( &self, options: &CodecOptions, ) -> Result<Option<ArrayBytesRaw<'_>>, CodecError>

Decode all bytes.

Returns None if partial decoding of the input handle returns None.

§Errors

Returns CodecError if a codec fails.

Implementations on Foreign Types§

Source§

impl BytesPartialDecoderTraits for Cow<'static, [u8]>

Source§

impl BytesPartialDecoderTraits for Vec<u8>

Source§

impl BytesPartialDecoderTraits for Mutex<Option<Vec<u8>>>

Implementors§