New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Binary key support + key trait #49
Conversation
src/keys/binary_key.rs
Outdated
/// | start end | ||
/// ``` | ||
#[derive(Debug, PartialEq, Clone)] | ||
pub struct BinaryKey(pub Vec<u8>, pub usize, pub usize); // (key data, offset in first byte, offset in last byte) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: instead of exposing the underlying byte-based structure, let the calling code use general bit offsets. By that I mean the first bit from left has offset 0 and if the key length is 16, the last bit (rightmost) has offset 15. This feels more intuitive for me.
Although I can see when you repeatedly want to slice the key, then those offsets change.
So after considering the iterator route for some time, and in spite of being convinced that this is the best way in the long run, I also realized it was going to be fairly heavy work, and it's not currently necessary if it's just about not making a couple fields public. I will go ahead with this one in order to resume work on binary trees, and will fix that for the 2.x release. |
This is preparation work for the support of binary trees.
Key
trait that will have to be implemented by all objects that can be used as keys;BinaryKey
that implementsKey
and represents a bit-wise string;ByteKey
andNibbleKey
as an implementation ofKey
; andByteKey
,NibbleKey
andBinaryKey
to their own modules.