pub trait Key:
Copy
+ Send
+ Sync {
const KEY_SCHEME: KeyScheme;
const GROUP_BITS: u32 = 0;
// Required methods
fn as_bytes(&self) -> &[u8] ⓘ;
fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ;
fn from_bytes(bytes: &[u8]) -> Self;
fn zeroed() -> Self;
}Expand description
Key metadata trait — describes key encoding for armdb collections.
Analogous to Cid in the armour crate, but without encode/decode methods.
Only carries compile-time constants for TreeMeta construction.
Implementations must guarantee that the type is safe to transmute to/from
[u8; size_of::<Self>()] — all bit patterns valid, no padding.
Use [impl_key_zerocopy!] for zerocopy types or [impl_key_bytemuck!]
for bytemuck types to get correct implementations.
§Example
ⓘ
use armdb::{Key, impl_key_zerocopy};
use armour_core::{KeyScheme, KeyType};
impl_key_zerocopy!(UserId, KeyScheme::Typed(&[KeyType::Fuid]));Required Associated Constants§
Sourceconst KEY_SCHEME: KeyScheme
const KEY_SCHEME: KeyScheme
Key encoding scheme.
Provided Associated Constants§
Sourceconst GROUP_BITS: u32 = 0
const GROUP_BITS: u32 = 0
Bits used for group_id / shard routing.
Required Methods§
fn as_bytes(&self) -> &[u8] ⓘ
fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
fn from_bytes(bytes: &[u8]) -> Self
fn zeroed() -> Self
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".