Closed GopherJ closed 2 months ago
You can use &'static [u8]
in the TableDefinition
and still insert slices with any lifetime, and get slices with the lifetime of the AccessGuard
.
The lifetimes in the TableDefinition
are overwritten by the correct lifetime for the context using the associated SelfType
defined in Key
& Value
. e.g. Table::insert
is generic over the lifetimes of the key & value, ReadableTable::get
is generic over the lifetime of the key and the value has the lifetime of the guard.
redb has its own Key, Value traits but some applications may already do this in their own way and all they need is to be able to store:
Key: Vec\<u8> Value: Vec\<u8>
like other embedded databases, to do this in redb we will need to implement Key for Vec but Vec is an orphan type
Key is implemented for &[u8] but since TableDefinition requires 'static lifetime so we can only use &'static [u8] which is not pratical