aboutsummaryrefslogtreecommitdiff
path: root/common/object
diff options
context:
space:
mode:
Diffstat (limited to 'common/object')
-rw-r--r--common/object/src/buffer.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/common/object/src/buffer.rs b/common/object/src/buffer.rs
index 703e203..1f8cec6 100644
--- a/common/object/src/buffer.rs
+++ b/common/object/src/buffer.rs
@@ -54,9 +54,14 @@ impl ObjectBuffer {
}
}
+pub type OBB = ObjectBufferBuilder;
+
#[derive(Default)]
pub struct ObjectBufferBuilder(Vec<(Tag, u32, Vec<u32>)>);
impl ObjectBufferBuilder {
+ pub fn new() -> Self {
+ Self::default()
+ }
pub fn push<T: ValueStore>(&mut self, tag: TypedTag<T>, value: T) {
let ty = value.get_type();
let tyb = (ty as u32) << 2;
@@ -71,6 +76,10 @@ impl ObjectBufferBuilder {
self.0.push((tag.0, tyb | pad, vec_u8_to_u32(buf)));
}
}
+ pub fn with<T: ValueStore>(mut self, tag: TypedTag<T>, value: T) -> Self {
+ self.push(tag, value);
+ self
+ }
pub fn finish(mut self) -> ObjectBuffer {
let mut tags = Vec::new();
let mut offsets = Vec::new();