aboutsummaryrefslogtreecommitdiff
path: root/native/treebitmap_nif/src/nibbles.rs
diff options
context:
space:
mode:
Diffstat (limited to 'native/treebitmap_nif/src/nibbles.rs')
-rw-r--r--native/treebitmap_nif/src/nibbles.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/native/treebitmap_nif/src/nibbles.rs b/native/treebitmap_nif/src/nibbles.rs
new file mode 100644
index 0000000..ca1939b
--- /dev/null
+++ b/native/treebitmap_nif/src/nibbles.rs
@@ -0,0 +1,32 @@
+pub struct NibblesV4 {
+ pub n: [u8; 8],
+}
+pub struct NibblesV6 {
+ pub n: [u8; 32],
+}
+
+pub enum Nibbles {
+ V4(NibblesV4),
+ V6(NibblesV6),
+}
+
+impl AsRef<[u8]> for Nibbles {
+ fn as_ref(&self) -> &[u8] {
+ match self {
+ Nibbles::V4(nib4) => nib4.as_ref(),
+ Nibbles::V6(nib6) => nib6.as_ref(),
+ }
+ }
+}
+
+impl AsRef<[u8]> for NibblesV4 {
+ fn as_ref(&self) -> &[u8] {
+ &self.n
+ }
+}
+
+impl AsRef<[u8]> for NibblesV6 {
+ fn as_ref(&self) -> &[u8] {
+ &self.n
+ }
+}