1
0
Fork 0
forked from wry/wry

config: remove bincode command bridge

This commit is contained in:
kossLAN 2026-05-29 18:05:41 -04:00
parent d8920ed7a0
commit 87de5fcca3
No known key found for this signature in database
6 changed files with 64 additions and 119 deletions

View file

@ -37,15 +37,13 @@ use {
errorfmt::ErrorFmt,
numcell::NumCell,
oserror::OsErrorExt,
stack::Stack,
timer::{TimerError, TimerFd},
},
},
bincode::Options,
jay_config::{
_private::{
ClientCriterionIpc, ClientCriterionStringField, GenericCriterionIpc, PollableId,
WindowCriterionIpc, WindowCriterionStringField, WireMode, bincode_ops,
ConfigHandler, Unref, WindowCriterionIpc, WindowCriterionStringField, WireMode,
ipc::{ClientMessage, Response, ServerMessage, WorkspaceSource},
},
Axis, Direction, Workspace,
@ -93,12 +91,11 @@ pub(super) struct ConfigProxyHandler {
pub client_data: Cell<*const u8>,
pub dropped: Cell<bool>,
pub _version: u32,
pub unref: unsafe extern "C" fn(data: *const u8),
pub handle_msg: unsafe extern "C" fn(data: *const u8, msg: *const u8, size: usize),
pub unref: Unref,
pub handle_msg: ConfigHandler,
pub state: Rc<State>,
pub next_id: NumCell<u64>,
pub keymaps: CopyHashMap<Keymap, Rc<KbvmMap>>,
pub bufs: Stack<Vec<u8>>,
pub workspace_ids: NumCell<u64>,
pub workspaces_by_name: CopyHashMap<Rc<String>, u64>,
@ -202,13 +199,9 @@ impl ConfigProxyHandler {
}
pub fn send(&self, msg: &ServerMessage) {
let mut buf = self.bufs.pop().unwrap_or_default();
buf.clear();
bincode_ops().serialize_into(&mut buf, msg).unwrap();
unsafe {
(self.handle_msg)(self.client_data.get(), buf.as_ptr(), buf.len());
(self.handle_msg)(self.client_data.get(), msg);
}
self.bufs.push(buf);
}
pub fn respond(&self, msg: Response) {
@ -2813,17 +2806,14 @@ impl ConfigProxyHandler {
Ok(())
}
pub fn handle_request(self: &Rc<Self>, msg: &[u8]) {
pub fn handle_request(self: &Rc<Self>, msg: &ClientMessage<'_>) {
if let Err(e) = self.handle_request_(msg) {
log::error!("Could not handle client request: {}", ErrorFmt(e));
}
}
fn handle_request_(self: &Rc<Self>, msg: &[u8]) -> Result<(), CphError> {
let request = match bincode_ops().deserialize::<ClientMessage>(msg) {
Ok(msg) => msg,
Err(e) => return Err(CphError::ParsingFailed(e)),
};
fn handle_request_(self: &Rc<Self>, request: &ClientMessage<'_>) -> Result<(), CphError> {
let request = request.clone();
match request {
ClientMessage::Log {
level,
@ -3599,8 +3589,6 @@ enum CphError {
UnknownColor(u32),
#[error("Sized element {0} is not known")]
UnknownSized(u32),
#[error("Could not parse the message")]
ParsingFailed(#[source] bincode::Error),
#[error("Could not process a `{0}` request")]
FailedRequest(&'static str, #[source] Box<Self>),
#[error(transparent)]