1
0
Fork 0
forked from wry/wry

autocommit 2022-01-04 15:30:21 CET

This commit is contained in:
Julian Orth 2022-01-04 15:30:21 +01:00
parent 30376c595c
commit cbbc41a463
40 changed files with 725 additions and 189 deletions

View file

@ -1,7 +1,7 @@
use crate::object::ObjectId;
use crate::utils::buffd::buf_out::{BufFdOut, MsgFds};
use std::mem;
use std::mem::{MaybeUninit};
use std::mem::MaybeUninit;
use uapi::OwnedFd;
pub struct MsgFormatter<'a> {
@ -50,11 +50,11 @@ impl<'a> MsgFormatter<'a> {
self
}
pub fn object(&mut self, obj: ObjectId) -> &mut Self {
self.uint(obj.raw())
pub fn object<T: Into<ObjectId>>(&mut self, obj: T) -> &mut Self {
self.uint(obj.into().raw())
}
pub fn header(&mut self, obj: ObjectId, event: u32) -> &mut Self {
pub fn header<T: Into<ObjectId>>(&mut self, obj: T, event: u32) -> &mut Self {
self.object(obj).uint(event)
}

View file

@ -46,8 +46,11 @@ impl<'a, 'b> MsgParser<'a, 'b> {
self.int().map(|i| i as u32)
}
pub fn object(&mut self) -> Result<ObjectId, MsgParserError> {
self.int().map(|i| ObjectId::from_raw(i as u32))
pub fn object<T>(&mut self) -> Result<T, MsgParserError>
where
ObjectId: Into<T>,
{
self.int().map(|i| ObjectId::from_raw(i as u32).into())
}
pub fn global(&mut self) -> Result<GlobalName, MsgParserError> {