diff options
Diffstat (limited to 'common/object/src/value.rs')
| -rw-r--r-- | common/object/src/value.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/common/object/src/value.rs b/common/object/src/value.rs index d77d53a..1b24e79 100644 --- a/common/object/src/value.rs +++ b/common/object/src/value.rs @@ -107,3 +107,37 @@ impl ValueStore for ObjectBuffer { self.0.len() * 4 } } +impl<'a> Value<'a> for &'a [u8] { + const ALIGNED: bool = false; + fn load_unaligned(buf: &'a [u8]) -> Option<Self> { + Some(buf) + } +} +impl ValueStore for &[u8] { + fn is_aligned(&self) -> bool { + false + } + fn store_unaligned(&self, buf: &mut Vec<u8>) { + buf.extend(*self); + } + fn size(&self) -> usize { + 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 + } +} |