Module bonsaidb_core::key
source · Expand description
Key trait and related types.
Modules
Key
implementations for time types.
Structs
- Prevents checking for null bytes in variable length fields in composite keys.
Key
types that have a fixed width have no edge cases with null bytes. SeeCompositeKeyFieldContainsNullByte
for an explanation and example of the edge case introduced when allowing null bytes to be used without escaping. - Decodes multiple
Key
values from a byte slice previously encoded withCompositeKeyEncoder
. - A description of a multi-field key encoded using
CompositeKeyEncoder
. - Encodes multiple
KeyEncoding
implementors into a single byte buffer, preserving the ordering guarantees necessary forKey
. - An error occurred inside of one of the composite key fields.
- Null bytes in variable fields encoded with
CompositeKeyEncoder
can cause sort order to misbehave. - Checks for null bytes when encoding variable length fields in composite keys and returns an error if any are encountered. This prevents extra processing when encoding fields, but may introduce incorrect sort ordering (see
CompositeKeyFieldContainsNullByte
for more). - Adds
Key
support to an enum. Requires implementingToPrimitive
andFromPrimitive
, or using a crate like num-derive to do it automatically. Take care when using enums as keys: if the order changes or if the meaning of existing numerical values changes, make sure to update any related views’ version number to ensure the values are re-evaluated. - Escapes null bytes in variable length fields in composite keys. This option ensures proper sort order is maintained even when null bytes are used within vairable fields.
- An error that indicates an unexpected number of bytes were present.
- OptionKeyV1DeprecatedA type that preserves the original implementation of
Key
forOption<T>
. This should not be used in new code and will be removed in a future version. - TupleEncodingV1DeprecatedThis type enables wrapping a tuple to preserve the behavior of the initial implementation of tuple key encoding. This type should not be used in new code and should only be used to preserve backwards compatibility. See https://github.com/khonsulabs/bonsaidb/issues/240 for more information about why this implementation should be avoided.
- An error that indicates an unexpected enum variant value was found.
- A wrapper type for Rust’s built-in integer types that encodes with variable length and implements the
Key
trait.
Enums
- A source of bytes from a
&'borrowed [u8]
,&'ephemeral [u8]
orVec<u8>
. - A description of the kind of a composite key.
- A value used as part of
KeyVisitor::visit_composite_attribute
. - A description of an encoded
Key
. - The type of a single field contained in a key.
- The error types for
Key::next_value()
. - An error occurred during a
Key
orKeyEncoding
implementation for a non-zero type.
Traits
- A null-byte handling approach for
CompositeKeyEncoder
andCompositeKeyDecoder
. This type is only used when the fields being encoded are variable length. - A type that can be used as a prefix range in range-based queries.
- A trait that enables a type to convert itself into a
memcmp
-compatible sequence of bytes. - A trait that enables a type to convert itself into a
memcmp
-compatible sequence of bytes. - A Visitor for information about a
KeyEncoding
. - A type that is compatible with
VarInt
.
Functions
- decode_composite_fieldDeprecatedDecodes a value previously encoded using
encode_composite_field()
. The result is a tuple with the first element being the decoded value, and the second element is the remainig byte slice. - encode_composite_fieldDeprecatedEncodes a value using the
Key
trait in such a way that multiple values can still be ordered at the byte level when chained together.
Derive Macros
- Derives the
bonsaidb::core::key::Key
trait.