Skip to main content

KeySchema

Trait KeySchema 

Source
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§

Source

const SEGMENT_PERM: &'static [usize]

Order of segments from key layout to tree layout.

Source

const KEY_TO_TREE: [usize; KEY_LEN]

Maps each key index to its position in the tree view.

Source

const TREE_TO_KEY: [usize; KEY_LEN]

Maps each tree index to its position in the key view.

Required Associated Types§

Source

type Segmentation: KeySegmentation<KEY_LEN>

The segmentation this ordering operates over.

Provided Methods§

Source

fn tree_ordered(key: &[u8; KEY_LEN]) -> [u8; KEY_LEN]

Reorders the key from the shared key ordering to the tree ordering.

Source

fn key_ordered(tree_key: &[u8; KEY_LEN]) -> [u8; KEY_LEN]

Reorders the key from the tree ordering to the shared key ordering.

Source

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.

Source

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.

Implementors§

Source§

impl KeySchema<TRIBLE_LEN> for AEVOrder

Source§

impl KeySchema<TRIBLE_LEN> for AVEOrder

Source§

impl KeySchema<TRIBLE_LEN> for EAVOrder

Source§

impl KeySchema<TRIBLE_LEN> for EVAOrder

Source§

impl KeySchema<TRIBLE_LEN> for VAEOrder

Source§

impl KeySchema<TRIBLE_LEN> for VEAOrder

Source§

impl<const KEY_LEN: usize> KeySchema<KEY_LEN> for IdentitySchema