Struct bonsaidb::core::key::CompositeKeyDecoder
source · pub struct CompositeKeyDecoder<'key, 'ephemeral, NullHandling = EscapeNullBytes> { /* private fields */ }
Expand description
Decodes multiple Key
values from a byte slice previously encoded with
CompositeKeyEncoder
.
Implementations§
source§impl<'key, 'ephemeral> CompositeKeyDecoder<'key, 'ephemeral>
impl<'key, 'ephemeral> CompositeKeyDecoder<'key, 'ephemeral>
sourcepub fn default_for(
bytes: ByteSource<'key, 'ephemeral>
) -> CompositeKeyDecoder<'key, 'ephemeral>
pub fn default_for( bytes: ByteSource<'key, 'ephemeral> ) -> CompositeKeyDecoder<'key, 'ephemeral>
Returns a decoder for bytes
that decodes escaped null bytes.
This function is compatible with keys encoded with
CompositeKeyEncoder::default()
.
source§impl<'key, 'ephemeral> CompositeKeyDecoder<'key, 'ephemeral, AllowNullBytes>
impl<'key, 'ephemeral> CompositeKeyDecoder<'key, 'ephemeral, AllowNullBytes>
sourcepub fn allowing_null_bytes(
bytes: ByteSource<'key, 'ephemeral>
) -> CompositeKeyDecoder<'key, 'ephemeral, AllowNullBytes>
pub fn allowing_null_bytes( bytes: ByteSource<'key, 'ephemeral> ) -> CompositeKeyDecoder<'key, 'ephemeral, AllowNullBytes>
Returns a decoder for bytes
that ignores null bytes.
This function is compatible with keys encoded with
CompositeKeyEncoder::allowing_null_bytes()
.
source§impl<'key, 'ephemeral> CompositeKeyDecoder<'key, 'ephemeral, DenyNullBytes>
impl<'key, 'ephemeral> CompositeKeyDecoder<'key, 'ephemeral, DenyNullBytes>
sourcepub fn denying_null_bytes(
bytes: ByteSource<'key, 'ephemeral>
) -> CompositeKeyDecoder<'key, 'ephemeral, DenyNullBytes>
pub fn denying_null_bytes( bytes: ByteSource<'key, 'ephemeral> ) -> CompositeKeyDecoder<'key, 'ephemeral, DenyNullBytes>
Returns a decoder for bytes
that ignores null bytes.
This function is compatible with keys encoded with
CompositeKeyEncoder::denying_null_bytes()
.
source§impl<'key, 'ephemeral, NullHandling> CompositeKeyDecoder<'key, 'ephemeral, NullHandling>where
NullHandling: CompositeKeyNullHandler,
impl<'key, 'ephemeral, NullHandling> CompositeKeyDecoder<'key, 'ephemeral, NullHandling>where
NullHandling: CompositeKeyNullHandler,
sourcepub fn decode<T>(&mut self) -> Result<T, CompositeKeyError>where
T: Key<'key>,
pub fn decode<T>(&mut self) -> Result<T, CompositeKeyError>where
T: Key<'key>,
Decodes a value previously encoded using CompositeKeyEncoder
. Calls
to decode must be made in the same order as the values were encoded in.
let value1 = String::from("hello");
let value2 = 42_u32;
let mut encoder = CompositeKeyEncoder::default();
encoder.encode(&value1).unwrap();
encoder.encode(&value2).unwrap();
let encoded = encoder.finish();
let mut decoder = CompositeKeyDecoder::default_for(ByteSource::Borrowed(&encoded));
let decoded_string = decoder.decode::<String>().unwrap();
assert_eq!(decoded_string, value1);
let decoded_u32 = decoder.decode::<u32>().unwrap();
assert_eq!(decoded_u32, value2);
decoder.finish().expect("trailing bytes");
sourcepub fn finish(self) -> Result<(), CompositeKeyError>
pub fn finish(self) -> Result<(), CompositeKeyError>
Verifies the underlying byte slice has been fully consumed.
Auto Trait Implementations§
impl<'key, 'ephemeral, NullHandling> RefUnwindSafe for CompositeKeyDecoder<'key, 'ephemeral, NullHandling>where
NullHandling: RefUnwindSafe,
impl<'key, 'ephemeral, NullHandling> Send for CompositeKeyDecoder<'key, 'ephemeral, NullHandling>where
NullHandling: Send,
impl<'key, 'ephemeral, NullHandling> Sync for CompositeKeyDecoder<'key, 'ephemeral, NullHandling>where
NullHandling: Sync,
impl<'key, 'ephemeral, NullHandling> Unpin for CompositeKeyDecoder<'key, 'ephemeral, NullHandling>where
NullHandling: Unpin,
impl<'key, 'ephemeral, NullHandling> UnwindSafe for CompositeKeyDecoder<'key, 'ephemeral, NullHandling>where
NullHandling: UnwindSafe,
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more