aboutsummaryrefslogtreecommitdiff
path: root/common/object/src/value.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2026-01-14 02:25:09 +0100
committermetamuffin <metamuffin@disroot.org>2026-01-14 02:25:09 +0100
commitb5ff460e938779be4eeab292c2cc1d436b93c137 (patch)
tree1c01ee1ca923ac4f302b312eb175aa77aa344a1d /common/object/src/value.rs
parent72a718fffb236c4b157e4d62c2e486ca7b326a26 (diff)
downloadjellything-b5ff460e938779be4eeab292c2cc1d436b93c137.tar
jellything-b5ff460e938779be4eeab292c2cc1d436b93c137.tar.bz2
jellything-b5ff460e938779be4eeab292c2cc1d436b93c137.tar.zst
Store object values as big endian; Draft query types
Diffstat (limited to 'common/object/src/value.rs')
-rw-r--r--common/object/src/value.rs29
1 files changed, 6 insertions, 23 deletions
diff --git a/common/object/src/value.rs b/common/object/src/value.rs
index 1b24e79..aad6101 100644
--- a/common/object/src/value.rs
+++ b/common/object/src/value.rs
@@ -43,7 +43,7 @@ impl ValueStore for &str {
impl Value<'_> for u32 {
const ALIGNED: bool = true;
fn load_aligned(buf: &[u32]) -> Option<Self> {
- buf.get(0).copied()
+ buf.get(0).copied().map(u32::from_be)
}
}
impl ValueStore for u32 {
@@ -51,7 +51,7 @@ impl ValueStore for u32 {
true
}
fn store_aligned(&self, buf: &mut Vec<u32>) {
- buf.push(*self);
+ buf.push(self.to_be());
}
fn size(&self) -> usize {
4
@@ -60,8 +60,8 @@ impl ValueStore for u32 {
impl Value<'_> for u64 {
const ALIGNED: bool = false;
fn load_aligned(buf: &[u32]) -> Option<Self> {
- let hi = *buf.get(0)? as u64;
- let lo = *buf.get(1)? as u64;
+ let hi = u32::from_be(*buf.get(0)?) as u64;
+ let lo = u32::from_be(*buf.get(1)?) as u64;
Some(hi << 32 | lo)
}
}
@@ -70,8 +70,8 @@ impl ValueStore for u64 {
true
}
fn store_aligned(&self, buf: &mut Vec<u32>) {
- buf.push((self >> 32) as u32);
- buf.push(*self as u32);
+ buf.push(((self >> 32) as u32).to_be());
+ buf.push((*self as u32).to_be());
}
fn size(&self) -> usize {
8
@@ -124,20 +124,3 @@ impl ValueStore for &[u8] {
self.len()
}
}
-impl<'a> Value<'a> for &'a [u32] {
- const ALIGNED: bool = true;
- fn load_aligned(buf: &'a [u32]) -> Option<Self> {
- Some(buf)
- }
-}
-impl ValueStore for &[u32] {
- fn is_aligned(&self) -> bool {
- true
- }
- fn store_aligned(&self, buf: &mut Vec<u32>) {
- buf.extend(*self);
- }
- fn size(&self) -> usize {
- self.len() * 4
- }
-}