pub trait KeySchema<const KEY_LEN: usize>:
Copy
+ Clone
+ Debug {
type Segmentation: KeySegmentation<KEY_LEN>;
const SEGMENT_PERM: &'static [usize];
const KEY_TO_TREE: [usize; KEY_LEN];
const TREE_TO_KEY: [usize; KEY_LEN];
// Provided methods
fn tree_ordered(key: &[u8; KEY_LEN]) -> [u8; KEY_LEN] { ... }
fn key_ordered(tree_key: &[u8; KEY_LEN]) -> [u8; KEY_LEN] { ... }
fn segment_of_tree_depth(at_depth: usize) -> usize { ... }
fn same_segment_tree(a: usize, b: usize) -> bool { ... }
}Expand description
A trait is used to provide a re-ordered view of the keys stored in the PATCH. This allows for different PATCH instances share the same leaf nodes, independent of the key ordering used in the tree.
Required Associated Constants§
Sourceconst SEGMENT_PERM: &'static [usize]
const SEGMENT_PERM: &'static [usize]
Order of segments from key layout to tree layout.
Sourceconst KEY_TO_TREE: [usize; KEY_LEN]
const KEY_TO_TREE: [usize; KEY_LEN]
Maps each key index to its position in the tree view.
Sourceconst TREE_TO_KEY: [usize; KEY_LEN]
const TREE_TO_KEY: [usize; KEY_LEN]
Maps each tree index to its position in the key view.
Required Associated Types§
Sourcetype Segmentation: KeySegmentation<KEY_LEN>
type Segmentation: KeySegmentation<KEY_LEN>
The segmentation this ordering operates over.
Provided Methods§
Sourcefn tree_ordered(key: &[u8; KEY_LEN]) -> [u8; KEY_LEN]
fn tree_ordered(key: &[u8; KEY_LEN]) -> [u8; KEY_LEN]
Reorders the key from the shared key ordering to the tree ordering.
Sourcefn key_ordered(tree_key: &[u8; KEY_LEN]) -> [u8; KEY_LEN]
fn key_ordered(tree_key: &[u8; KEY_LEN]) -> [u8; KEY_LEN]
Reorders the key from the tree ordering to the shared key ordering.
Sourcefn segment_of_tree_depth(at_depth: usize) -> usize
fn segment_of_tree_depth(at_depth: usize) -> usize
Return the segment index for the byte at at_depth in tree ordering.
Default implementation reads the static segmentation table and the tree->key mapping. Having this as a method makes call sites clearer and reduces the verbosity of expressions that access the segmentation table.
Sourcefn same_segment_tree(a: usize, b: usize) -> bool
fn same_segment_tree(a: usize, b: usize) -> bool
Return true if the tree-ordered bytes at a and b belong to the same
logical segment.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.