1
0
Fork 0
forked from wry/wry

autocommit 2022-02-06 16:33:54 CET

This commit is contained in:
Julian Orth 2022-02-06 16:33:54 +01:00
parent c92346324b
commit dc2cb71012
104 changed files with 2563 additions and 4617 deletions

View file

@ -60,6 +60,7 @@ impl<'a> MsgFormatter<'a> {
self.object(obj).uint(event)
}
#[allow(dead_code)]
pub fn array<F: FnOnce(&mut MsgFormatter<'_>)>(&mut self, f: F) -> &mut Self {
let pos = self.buf.out_pos;
self.uint(0);
@ -81,6 +82,14 @@ impl<'a> MsgFormatter<'a> {
self
}
pub fn binary<T: ?Sized>(&mut self, t: &T) -> &mut Self {
self.uint(mem::size_of_val(t) as u32);
self.buf.write(uapi::as_maybe_uninit_bytes(t));
let none = [MaybeUninit::new(0); 4];
self.buf.write(&none[..self.buf.out_pos.wrapping_neg() & 3]);
self
}
pub fn write_len(self) {
assert!(self.buf.out_pos - self.pos >= 8);
assert_eq!(self.pos % 4, 0);