aboutsummaryrefslogtreecommitdiff
path: root/common/object/src/buffer.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2026-01-06 19:10:37 +0100
committermetamuffin <metamuffin@disroot.org>2026-01-06 19:10:37 +0100
commitffa6b5c4ae2cdd3e07426ed0330f3f66e90ee57b (patch)
tree79a03bc7ed938a3698ece0878f0ce5337ff6db23 /common/object/src/buffer.rs
parentffbdb9ce397a6408d5a91cbdcbaf4e13b0c3ba0b (diff)
downloadjellything-ffa6b5c4ae2cdd3e07426ed0330f3f66e90ee57b.tar
jellything-ffa6b5c4ae2cdd3e07426ed0330f3f66e90ee57b.tar.bz2
jellything-ffa6b5c4ae2cdd3e07426ed0330f3f66e90ee57b.tar.zst
tag registry
Diffstat (limited to 'common/object/src/buffer.rs')
-rw-r--r--common/object/src/buffer.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/common/object/src/buffer.rs b/common/object/src/buffer.rs
index 56b8caf..dbde833 100644
--- a/common/object/src/buffer.rs
+++ b/common/object/src/buffer.rs
@@ -5,6 +5,7 @@
*/
use crate::{Object, Tag, ValueStore};
+use bytemuck::try_cast_vec;
pub struct ObjectBuffer(pub Vec<u32>);
@@ -48,3 +49,14 @@ impl ObjectBuffer {
)
}
}
+
+impl From<Vec<u8>> for ObjectBuffer {
+ fn from(value: Vec<u8>) -> Self {
+ ObjectBuffer(try_cast_vec(value).unwrap_or_else(|(_, v)| {
+ v.into_iter()
+ .array_chunks()
+ .map(u32::from_ne_bytes)
+ .collect()
+ }))
+ }
+}