aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/object/src/lib.rs3
-rw-r--r--common/object/src/value.rs29
-rw-r--r--common/src/lib.rs2
3 files changed, 8 insertions, 26 deletions
diff --git a/common/object/src/lib.rs b/common/object/src/lib.rs
index 7c97bee..ea64fd4 100644
--- a/common/object/src/lib.rs
+++ b/common/object/src/lib.rs
@@ -12,14 +12,13 @@ mod registry;
mod tests;
mod value;
pub use buffer::*;
-use bytemuck::NoUninit;
pub use registry::*;
pub use value::*;
use std::marker::PhantomData;
#[repr(transparent)]
-#[derive(NoUninit, Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub struct Tag(pub u32);
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
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
- }
-}
diff --git a/common/src/lib.rs b/common/src/lib.rs
index 2cbbfce..5641386 100644
--- a/common/src/lib.rs
+++ b/common/src/lib.rs
@@ -59,7 +59,7 @@ fields! {
CH_START: f64 = 29 "start";
CH_END: f64 = 30 "end";
- CH_NAME: f64 = 31 "name";
+ CH_NAME: &str = 31 "name";
LANG_NATIVE: &str = 0xa001 "native";
LANG_ENG: &str = 0xa002 "eng";