wire: move message buffers into workspace crates
This commit is contained in:
parent
d8380b3dce
commit
a1e4641e82
18 changed files with 187 additions and 166 deletions
21
Cargo.lock
generated
21
Cargo.lock
generated
|
|
@ -707,6 +707,8 @@ dependencies = [
|
||||||
"jay-tracy",
|
"jay-tracy",
|
||||||
"jay-units",
|
"jay-units",
|
||||||
"jay-utils",
|
"jay-utils",
|
||||||
|
"jay-wire-buf",
|
||||||
|
"jay-wire-types",
|
||||||
"jay-xcon",
|
"jay-xcon",
|
||||||
"kbvm",
|
"kbvm",
|
||||||
"libloading",
|
"libloading",
|
||||||
|
|
@ -884,6 +886,25 @@ dependencies = [
|
||||||
"uapi",
|
"uapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "jay-wire-buf"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"bstr",
|
||||||
|
"jay-io-uring",
|
||||||
|
"jay-time",
|
||||||
|
"jay-units",
|
||||||
|
"jay-utils",
|
||||||
|
"jay-wire-types",
|
||||||
|
"smallvec",
|
||||||
|
"thiserror",
|
||||||
|
"uapi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "jay-wire-types"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "jay-xcon"
|
name = "jay-xcon"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,8 @@ members = [
|
||||||
"bufio",
|
"bufio",
|
||||||
"dbus-core",
|
"dbus-core",
|
||||||
"xcon",
|
"xcon",
|
||||||
|
"wire-types",
|
||||||
|
"wire-buf",
|
||||||
"toml-config",
|
"toml-config",
|
||||||
"algorithms",
|
"algorithms",
|
||||||
"toml-spec",
|
"toml-spec",
|
||||||
|
|
@ -65,6 +67,8 @@ jay-io-uring = { version = "0.1.0", path = "io-uring" }
|
||||||
jay-bufio = { version = "0.1.0", path = "bufio" }
|
jay-bufio = { version = "0.1.0", path = "bufio" }
|
||||||
jay-dbus-core = { version = "0.1.0", path = "dbus-core" }
|
jay-dbus-core = { version = "0.1.0", path = "dbus-core" }
|
||||||
jay-xcon = { version = "0.1.0", path = "xcon" }
|
jay-xcon = { version = "0.1.0", path = "xcon" }
|
||||||
|
jay-wire-types = { version = "0.1.0", path = "wire-types" }
|
||||||
|
jay-wire-buf = { version = "0.1.0", path = "wire-buf" }
|
||||||
|
|
||||||
uapi = "0.2.13"
|
uapi = "0.2.13"
|
||||||
thiserror = "2.0.11"
|
thiserror = "2.0.11"
|
||||||
|
|
|
||||||
|
|
@ -9,41 +9,13 @@ use {
|
||||||
},
|
},
|
||||||
std::{
|
std::{
|
||||||
cmp::Ordering,
|
cmp::Ordering,
|
||||||
fmt::{Display, Formatter, LowerHex},
|
|
||||||
rc::Rc,
|
rc::Rc,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
pub use jay_wire_types::EiObjectId;
|
||||||
|
|
||||||
pub const EI_HANDSHAKE_ID: EiHandshakeId = EiHandshakeId::from_raw(0);
|
pub const EI_HANDSHAKE_ID: EiHandshakeId = EiHandshakeId::from_raw(0);
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Hash, Ord, PartialOrd, Eq, PartialEq)]
|
|
||||||
pub struct EiObjectId(u64);
|
|
||||||
|
|
||||||
impl EiObjectId {
|
|
||||||
#[expect(dead_code)]
|
|
||||||
pub const NONE: Self = EiObjectId(0);
|
|
||||||
|
|
||||||
pub fn from_raw(raw: u64) -> Self {
|
|
||||||
Self(raw)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn raw(self) -> u64 {
|
|
||||||
self.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Display for EiObjectId {
|
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
|
||||||
Display::fmt(&self.0, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl LowerHex for EiObjectId {
|
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
|
||||||
LowerHex::fmt(&self.0, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait EiObjectBase {
|
pub trait EiObjectBase {
|
||||||
fn id(&self) -> EiObjectId;
|
fn id(&self) -> EiObjectId;
|
||||||
fn version(&self) -> EiVersion;
|
fn version(&self) -> EiVersion;
|
||||||
|
|
|
||||||
|
|
@ -85,14 +85,10 @@ use {
|
||||||
},
|
},
|
||||||
arrayvec::ArrayVec,
|
arrayvec::ArrayVec,
|
||||||
linearize::{Linearize, StaticMap},
|
linearize::{Linearize, StaticMap},
|
||||||
std::{
|
std::{cell::Cell, error::Error, rc::Rc},
|
||||||
cell::Cell,
|
|
||||||
error::Error,
|
|
||||||
fmt::{Display, Formatter},
|
|
||||||
rc::Rc,
|
|
||||||
},
|
|
||||||
thiserror::Error,
|
thiserror::Error,
|
||||||
};
|
};
|
||||||
|
pub use jay_wire_types::GlobalName;
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum GlobalsError {
|
pub enum GlobalsError {
|
||||||
|
|
@ -112,25 +108,6 @@ pub struct GlobalError {
|
||||||
pub error: Box<dyn Error>,
|
pub error: Box<dyn Error>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
|
|
||||||
pub struct GlobalName(u32);
|
|
||||||
|
|
||||||
impl GlobalName {
|
|
||||||
pub fn from_raw(id: u32) -> Self {
|
|
||||||
Self(id)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn raw(self) -> u32 {
|
|
||||||
self.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Display for GlobalName {
|
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
|
||||||
Display::fmt(&self.0, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait GlobalBase {
|
pub trait GlobalBase {
|
||||||
fn name(&self) -> GlobalName;
|
fn name(&self) -> GlobalName;
|
||||||
fn bind<'a>(
|
fn bind<'a>(
|
||||||
|
|
@ -275,7 +252,7 @@ impl Globals {
|
||||||
removed: CopyHashMap::new(),
|
removed: CopyHashMap::new(),
|
||||||
outputs: Default::default(),
|
outputs: Default::default(),
|
||||||
seats: Default::default(),
|
seats: Default::default(),
|
||||||
singletons: StaticMap::from_fn(|_| GlobalName(0)),
|
singletons: StaticMap::from_fn(|_| GlobalName::from_raw(0)),
|
||||||
exposed: Default::default(),
|
exposed: Default::default(),
|
||||||
};
|
};
|
||||||
add_singletons(&mut slf);
|
add_singletons(&mut slf);
|
||||||
|
|
@ -293,7 +270,7 @@ impl Globals {
|
||||||
if id == 0 {
|
if id == 0 {
|
||||||
panic!("Global names overflowed");
|
panic!("Global names overflowed");
|
||||||
}
|
}
|
||||||
GlobalName(id)
|
GlobalName::from_raw(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn insert_no_broadcast<'a>(&'a self, global: Rc<dyn Global>) {
|
fn insert_no_broadcast<'a>(&'a self, global: Rc<dyn Global>) {
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ macro_rules! id {
|
||||||
#[derive(Debug, Copy, Clone, Hash, Ord, PartialOrd, Eq, PartialEq)]
|
#[derive(Debug, Copy, Clone, Hash, Ord, PartialOrd, Eq, PartialEq)]
|
||||||
pub struct $name(u32);
|
pub struct $name(u32);
|
||||||
|
|
||||||
#[expect(dead_code)]
|
#[allow(dead_code)]
|
||||||
impl $name {
|
impl $name {
|
||||||
pub const NONE: Self = $name(0);
|
pub const NONE: Self = $name(0);
|
||||||
|
|
||||||
|
|
@ -639,7 +639,7 @@ macro_rules! ei_id {
|
||||||
#[derive(Debug, Copy, Clone, Hash, Ord, PartialOrd, Eq, PartialEq)]
|
#[derive(Debug, Copy, Clone, Hash, Ord, PartialOrd, Eq, PartialEq)]
|
||||||
pub struct $name(u64);
|
pub struct $name(u64);
|
||||||
|
|
||||||
#[expect(dead_code)]
|
#[allow(dead_code)]
|
||||||
impl $name {
|
impl $name {
|
||||||
pub const NONE: Self = $name(0);
|
pub const NONE: Self = $name(0);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,35 +7,13 @@ use {
|
||||||
std::{
|
std::{
|
||||||
any::Any,
|
any::Any,
|
||||||
cmp::Ordering,
|
cmp::Ordering,
|
||||||
fmt::{Display, Formatter},
|
|
||||||
rc::Rc,
|
rc::Rc,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
pub use jay_wire_types::ObjectId;
|
||||||
|
|
||||||
pub const WL_DISPLAY_ID: WlDisplayId = WlDisplayId::from_raw(1);
|
pub const WL_DISPLAY_ID: WlDisplayId = WlDisplayId::from_raw(1);
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Hash, Ord, PartialOrd, Eq, PartialEq)]
|
|
||||||
pub struct ObjectId(u32);
|
|
||||||
|
|
||||||
impl ObjectId {
|
|
||||||
#[expect(dead_code)]
|
|
||||||
pub const NONE: Self = ObjectId(0);
|
|
||||||
|
|
||||||
pub fn from_raw(raw: u32) -> Self {
|
|
||||||
Self(raw)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn raw(self) -> u32 {
|
|
||||||
self.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Display for ObjectId {
|
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
|
||||||
Display::fmt(&self.0, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait ObjectBase: Any {
|
pub trait ObjectBase: Any {
|
||||||
fn id(&self) -> ObjectId;
|
fn id(&self) -> ObjectId;
|
||||||
fn version(&self) -> Version;
|
fn version(&self) -> Version;
|
||||||
|
|
|
||||||
|
|
@ -1,43 +1 @@
|
||||||
use {crate::io_uring::IoUringError, thiserror::Error};
|
pub use jay_wire_buf::*;
|
||||||
pub use {
|
|
||||||
buf_in::BufFdIn,
|
|
||||||
buf_out::{BufFdOut, OutBuffer, OutBufferSwapchain},
|
|
||||||
ei_formatter::EiMsgFormatter,
|
|
||||||
ei_parser::{EiMsgParser, EiMsgParserError},
|
|
||||||
formatter::MsgFormatter,
|
|
||||||
parser::{MsgParser, MsgParserError},
|
|
||||||
wl_buf_in::{WlBufFdIn, WlMessage},
|
|
||||||
};
|
|
||||||
|
|
||||||
mod buf_in;
|
|
||||||
mod buf_out;
|
|
||||||
mod ei_formatter;
|
|
||||||
mod ei_parser;
|
|
||||||
mod formatter;
|
|
||||||
mod parser;
|
|
||||||
mod wl_buf_in;
|
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
|
||||||
pub enum BufFdError {
|
|
||||||
#[error("An IO error occurred")]
|
|
||||||
Io(#[source] IoUringError),
|
|
||||||
#[error("An io-uring error occurred")]
|
|
||||||
Ring(#[from] IoUringError),
|
|
||||||
#[error("The peer did not send a file descriptor")]
|
|
||||||
NoFd,
|
|
||||||
#[error("The peer sent too many file descriptors")]
|
|
||||||
TooManyFds,
|
|
||||||
#[error("The peer closed the connection")]
|
|
||||||
Closed,
|
|
||||||
#[error("The connection timed out")]
|
|
||||||
Timeout,
|
|
||||||
#[error("Message size is not a multiple of 4")]
|
|
||||||
UnalignedMessageSize,
|
|
||||||
#[error("Message size is larger than 4096")]
|
|
||||||
MessageTooLarge,
|
|
||||||
#[error("Message size is smaller than 8")]
|
|
||||||
MessageTooSmall,
|
|
||||||
}
|
|
||||||
|
|
||||||
const BUF_SIZE: usize = 4096;
|
|
||||||
const MAX_IN_FD: usize = 32;
|
|
||||||
|
|
|
||||||
17
wire-buf/Cargo.toml
Normal file
17
wire-buf/Cargo.toml
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
[package]
|
||||||
|
name = "jay-wire-buf"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
license = "GPL-3.0-only"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
jay-io-uring = { version = "0.1.0", path = "../io-uring" }
|
||||||
|
jay-time = { version = "0.1.0", path = "../time" }
|
||||||
|
jay-units = { version = "0.1.0", path = "../units" }
|
||||||
|
jay-utils = { version = "0.1.0", path = "../utils" }
|
||||||
|
jay-wire-types = { version = "0.1.0", path = "../wire-types" }
|
||||||
|
|
||||||
|
bstr = { version = "1.9.0", default-features = false, features = ["std"] }
|
||||||
|
smallvec = { version = "1.11.1", features = ["const_generics", "const_new", "union"] }
|
||||||
|
thiserror = "2.0.11"
|
||||||
|
uapi = "0.2.13"
|
||||||
|
|
@ -1,11 +1,7 @@
|
||||||
use {
|
use {
|
||||||
crate::{
|
crate::{BUF_SIZE, BufFdError, MAX_IN_FD},
|
||||||
io_uring::IoUring,
|
jay_io_uring::IoUring,
|
||||||
utils::{
|
jay_utils::buf::Buf,
|
||||||
buf::Buf,
|
|
||||||
buffd::{BUF_SIZE, BufFdError, MAX_IN_FD},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
smallvec::SmallVec,
|
smallvec::SmallVec,
|
||||||
std::{collections::VecDeque, mem::MaybeUninit, rc::Rc},
|
std::{collections::VecDeque, mem::MaybeUninit, rc::Rc},
|
||||||
uapi::{OwnedFd, Pod},
|
uapi::{OwnedFd, Pod},
|
||||||
|
|
@ -1,13 +1,8 @@
|
||||||
use {
|
use {
|
||||||
crate::{
|
crate::{BUF_SIZE, BufFdError},
|
||||||
io_uring::{IoUring, IoUringError},
|
jay_io_uring::{IoUring, IoUringError},
|
||||||
time::Time,
|
jay_time::Time,
|
||||||
utils::{
|
jay_utils::{buf::Buf, oserror::OsError},
|
||||||
buf::Buf,
|
|
||||||
buffd::{BUF_SIZE, BufFdError},
|
|
||||||
oserror::OsError,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
std::{
|
std::{
|
||||||
collections::VecDeque,
|
collections::VecDeque,
|
||||||
mem::{self},
|
mem::{self},
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
use {
|
use {
|
||||||
crate::{
|
crate::buf_out::{MsgFds, OUT_BUF_SIZE, OutBuffer, OutBufferMeta},
|
||||||
ei::ei_object::EiObjectId,
|
jay_wire_types::EiObjectId,
|
||||||
utils::buffd::buf_out::{MsgFds, OUT_BUF_SIZE, OutBuffer, OutBufferMeta},
|
|
||||||
},
|
|
||||||
std::{mem, rc::Rc},
|
std::{mem, rc::Rc},
|
||||||
uapi::OwnedFd,
|
uapi::OwnedFd,
|
||||||
};
|
};
|
||||||
|
|
@ -42,7 +40,6 @@ impl<'a> EiMsgFormatter<'a> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[expect(dead_code)]
|
|
||||||
pub fn long(&mut self, int: i64) -> &mut Self {
|
pub fn long(&mut self, int: i64) -> &mut Self {
|
||||||
self.write(uapi::as_bytes(&int));
|
self.write(uapi::as_bytes(&int));
|
||||||
self
|
self
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
use {
|
use {
|
||||||
crate::{ei::ei_object::EiObjectId, utils::buffd::BufFdIn},
|
crate::BufFdIn,
|
||||||
|
jay_wire_types::EiObjectId,
|
||||||
std::{ptr, rc::Rc},
|
std::{ptr, rc::Rc},
|
||||||
thiserror::Error,
|
thiserror::Error,
|
||||||
uapi::OwnedFd,
|
uapi::OwnedFd,
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
use {
|
use {
|
||||||
crate::{
|
crate::buf_out::{MsgFds, OUT_BUF_SIZE, OutBuffer, OutBufferMeta},
|
||||||
fixed::Fixed,
|
jay_units::Fixed,
|
||||||
object::ObjectId,
|
jay_wire_types::ObjectId,
|
||||||
utils::buffd::buf_out::{MsgFds, OUT_BUF_SIZE, OutBuffer, OutBufferMeta},
|
|
||||||
},
|
|
||||||
std::{mem, rc::Rc},
|
std::{mem, rc::Rc},
|
||||||
uapi::{OwnedFd, Packed},
|
uapi::{OwnedFd, Packed},
|
||||||
};
|
};
|
||||||
|
|
@ -48,13 +46,11 @@ impl<'a> MsgFormatter<'a> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[expect(dead_code)]
|
|
||||||
pub fn u64(&mut self, int: u64) -> &mut Self {
|
pub fn u64(&mut self, int: u64) -> &mut Self {
|
||||||
self.uint((int >> 32) as u32);
|
self.uint((int >> 32) as u32);
|
||||||
self.uint(int as u32)
|
self.uint(int as u32)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[expect(dead_code)]
|
|
||||||
pub fn u64_rev(&mut self, int: u64) -> &mut Self {
|
pub fn u64_rev(&mut self, int: u64) -> &mut Self {
|
||||||
self.uint(int as u32);
|
self.uint(int as u32);
|
||||||
self.uint((int >> 32) as u32)
|
self.uint((int >> 32) as u32)
|
||||||
|
|
@ -96,7 +92,6 @@ impl<'a> MsgFormatter<'a> {
|
||||||
self.object(obj).uint(event)
|
self.object(obj).uint(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[expect(dead_code)]
|
|
||||||
pub fn array<F: FnOnce(&mut MsgFormatter<'_>)>(&mut self, f: F) -> &mut Self {
|
pub fn array<F: FnOnce(&mut MsgFormatter<'_>)>(&mut self, f: F) -> &mut Self {
|
||||||
let pos = self.meta.write_pos;
|
let pos = self.meta.write_pos;
|
||||||
self.uint(0);
|
self.uint(0);
|
||||||
43
wire-buf/src/lib.rs
Normal file
43
wire-buf/src/lib.rs
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
use {jay_io_uring::IoUringError, thiserror::Error};
|
||||||
|
pub use {
|
||||||
|
buf_in::BufFdIn,
|
||||||
|
buf_out::{BufFdOut, OutBuffer, OutBufferSwapchain},
|
||||||
|
ei_formatter::EiMsgFormatter,
|
||||||
|
ei_parser::{EiMsgParser, EiMsgParserError},
|
||||||
|
formatter::MsgFormatter,
|
||||||
|
parser::{MsgParser, MsgParserError},
|
||||||
|
wl_buf_in::{WlBufFdIn, WlMessage},
|
||||||
|
};
|
||||||
|
|
||||||
|
mod buf_in;
|
||||||
|
mod buf_out;
|
||||||
|
mod ei_formatter;
|
||||||
|
mod ei_parser;
|
||||||
|
mod formatter;
|
||||||
|
mod parser;
|
||||||
|
mod wl_buf_in;
|
||||||
|
|
||||||
|
#[derive(Debug, Error)]
|
||||||
|
pub enum BufFdError {
|
||||||
|
#[error("An IO error occurred")]
|
||||||
|
Io(#[source] IoUringError),
|
||||||
|
#[error("An io-uring error occurred")]
|
||||||
|
Ring(#[from] IoUringError),
|
||||||
|
#[error("The peer did not send a file descriptor")]
|
||||||
|
NoFd,
|
||||||
|
#[error("The peer sent too many file descriptors")]
|
||||||
|
TooManyFds,
|
||||||
|
#[error("The peer closed the connection")]
|
||||||
|
Closed,
|
||||||
|
#[error("The connection timed out")]
|
||||||
|
Timeout,
|
||||||
|
#[error("Message size is not a multiple of 4")]
|
||||||
|
UnalignedMessageSize,
|
||||||
|
#[error("Message size is larger than 4096")]
|
||||||
|
MessageTooLarge,
|
||||||
|
#[error("Message size is smaller than 8")]
|
||||||
|
MessageTooSmall,
|
||||||
|
}
|
||||||
|
|
||||||
|
const BUF_SIZE: usize = 4096;
|
||||||
|
const MAX_IN_FD: usize = 32;
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
use {
|
use {
|
||||||
crate::{fixed::Fixed, globals::GlobalName, object::ObjectId},
|
|
||||||
bstr::{BStr, ByteSlice},
|
bstr::{BStr, ByteSlice},
|
||||||
|
jay_units::Fixed,
|
||||||
|
jay_wire_types::{GlobalName, ObjectId},
|
||||||
std::{collections::VecDeque, ptr, rc::Rc},
|
std::{collections::VecDeque, ptr, rc::Rc},
|
||||||
thiserror::Error,
|
thiserror::Error,
|
||||||
uapi::{OwnedFd, Pod},
|
uapi::{OwnedFd, Pod},
|
||||||
|
|
@ -55,14 +56,12 @@ impl<'a, 'b> MsgParser<'a, 'b> {
|
||||||
self.int().map(|i| i as u32)
|
self.int().map(|i| i as u32)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[expect(dead_code)]
|
|
||||||
pub fn u64(&mut self) -> Result<u64, MsgParserError> {
|
pub fn u64(&mut self) -> Result<u64, MsgParserError> {
|
||||||
let hi = self.uint()?;
|
let hi = self.uint()?;
|
||||||
let lo = self.uint()?;
|
let lo = self.uint()?;
|
||||||
Ok(((hi as u64) << 32) | lo as u64)
|
Ok(((hi as u64) << 32) | lo as u64)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[expect(dead_code)]
|
|
||||||
pub fn u64_rev(&mut self) -> Result<u64, MsgParserError> {
|
pub fn u64_rev(&mut self) -> Result<u64, MsgParserError> {
|
||||||
let lo = self.uint()?;
|
let lo = self.uint()?;
|
||||||
let hi = self.uint()?;
|
let hi = self.uint()?;
|
||||||
|
|
@ -76,7 +75,6 @@ impl<'a, 'b> MsgParser<'a, 'b> {
|
||||||
self.int().map(|i| ObjectId::from_raw(i as u32).into())
|
self.int().map(|i| ObjectId::from_raw(i as u32).into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[expect(dead_code)]
|
|
||||||
pub fn global(&mut self) -> Result<GlobalName, MsgParserError> {
|
pub fn global(&mut self) -> Result<GlobalName, MsgParserError> {
|
||||||
self.int().map(|i| GlobalName::from_raw(i as u32))
|
self.int().map(|i| GlobalName::from_raw(i as u32))
|
||||||
}
|
}
|
||||||
|
|
@ -1,12 +1,8 @@
|
||||||
use {
|
use {
|
||||||
crate::{
|
crate::{BufFdError, MAX_IN_FD},
|
||||||
io_uring::IoUring,
|
jay_io_uring::IoUring,
|
||||||
object::ObjectId,
|
jay_utils::buf::Buf,
|
||||||
utils::{
|
jay_wire_types::ObjectId,
|
||||||
buf::Buf,
|
|
||||||
buffd::{BufFdError, MAX_IN_FD},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
std::{collections::VecDeque, ptr, rc::Rc, slice},
|
std::{collections::VecDeque, ptr, rc::Rc, slice},
|
||||||
uapi::OwnedFd,
|
uapi::OwnedFd,
|
||||||
};
|
};
|
||||||
5
wire-types/Cargo.toml
Normal file
5
wire-types/Cargo.toml
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
[package]
|
||||||
|
name = "jay-wire-types"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
license = "GPL-3.0-only"
|
||||||
68
wire-types/src/lib.rs
Normal file
68
wire-types/src/lib.rs
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
use std::fmt::{Display, Formatter, LowerHex};
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, Hash, Ord, PartialOrd, Eq, PartialEq)]
|
||||||
|
pub struct ObjectId(u32);
|
||||||
|
|
||||||
|
impl ObjectId {
|
||||||
|
pub const NONE: Self = ObjectId(0);
|
||||||
|
|
||||||
|
pub fn from_raw(raw: u32) -> Self {
|
||||||
|
Self(raw)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn raw(self) -> u32 {
|
||||||
|
self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Display for ObjectId {
|
||||||
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
|
Display::fmt(&self.0, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
|
||||||
|
pub struct GlobalName(u32);
|
||||||
|
|
||||||
|
impl GlobalName {
|
||||||
|
pub fn from_raw(id: u32) -> Self {
|
||||||
|
Self(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn raw(self) -> u32 {
|
||||||
|
self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Display for GlobalName {
|
||||||
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
|
Display::fmt(&self.0, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, Hash, Ord, PartialOrd, Eq, PartialEq)]
|
||||||
|
pub struct EiObjectId(u64);
|
||||||
|
|
||||||
|
impl EiObjectId {
|
||||||
|
pub const NONE: Self = EiObjectId(0);
|
||||||
|
|
||||||
|
pub fn from_raw(raw: u64) -> Self {
|
||||||
|
Self(raw)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn raw(self) -> u64 {
|
||||||
|
self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Display for EiObjectId {
|
||||||
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
|
Display::fmt(&self.0, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl LowerHex for EiObjectId {
|
||||||
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
|
LowerHex::fmt(&self.0, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue