pub trait Key {
// Required method
fn to_bytes(&self) -> Vec<u8> ⓘ;
}
Expand description
Trait represent [Art] key. Trait define method which convert key into byte comparable sequence. This sequence will be used to order keys inside tree.
Required Methods§
Sourcefn to_bytes(&self) -> Vec<u8> ⓘ
fn to_bytes(&self) -> Vec<u8> ⓘ
Converts key to byte comparable sequence. This sequence used to represent key inside [Art] tree.
§Warning
Implementation must ensure that returned bytes vector have consistent order of bytes. E.g.
key type must have same ordering guarantees as returned byte sequence.
For instance, if "abc" < "def"
, then "abc".to_bytes() < "def".to_bytes()
.
Violation of this rule is undefined behaviour and can cause panic
.