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

@ -6,11 +6,10 @@ use {
tree::OutputNode,
utils::{copyhashmap::CopyHashMap, stack::Stack},
},
bincode::Options,
isnt::std_1::primitive::IsntConstPtrExt,
jay_config::{
_private::{
ConfigEntry, VERSION, bincode_ops,
ConfigEntry, VERSION,
ipc::{ClientMessage, Response, ServerMessage},
},
Axis, Direction,
@ -53,12 +52,11 @@ where
res
}
unsafe extern "C" fn init(
unsafe fn init(
srv_data: *const u8,
srv_unref: unsafe extern "C" fn(data: *const u8),
srv_handler: unsafe extern "C" fn(data: *const u8, msg: *const u8, size: usize),
_msg: *const u8,
_size: usize,
srv_unref: jay_config::_private::Unref,
srv_handler: jay_config::_private::ServerHandler,
_msg: jay_config::_private::ipc::InitMessage,
) -> *const u8 {
let tc = CONFIG.get();
assert!(tc.is_not_null());
@ -76,23 +74,15 @@ unsafe extern "C" fn init(
}
}
unsafe extern "C" fn unref(data: *const u8) {
unsafe fn unref(data: *const u8) {
unsafe {
Rc::decrement_strong_count(data.cast::<TestConfig>());
}
}
unsafe extern "C" fn handle_msg(data: *const u8, msg: *const u8, size: usize) {
unsafe fn handle_msg(data: *const u8, msg: &ServerMessage) {
let tc = unsafe { &*data.cast::<TestConfig>() };
let msg = unsafe { std::slice::from_raw_parts(msg, size) };
let res = bincode_ops().deserialize::<ServerMessage>(msg);
let msg = match res {
Ok(msg) => msg,
Err(e) => {
log::error!("could not deserialize message: {}", e);
return;
}
};
let msg = msg.clone();
match msg {
ServerMessage::Configure { .. } => {}
ServerMessage::Response { response } => {
@ -138,8 +128,8 @@ unsafe extern "C" fn handle_msg(data: *const u8, msg: *const u8, size: usize) {
#[derive(Copy, Clone)]
struct ServerData {
srv_data: *const u8,
srv_unref: unsafe extern "C" fn(data: *const u8),
srv_handler: unsafe extern "C" fn(data: *const u8, msg: *const u8, size: usize),
srv_unref: jay_config::_private::Unref,
srv_handler: jay_config::_private::ServerHandler,
}
pub struct TestConfig {
@ -170,10 +160,8 @@ impl TestConfig {
Some(srv) => srv,
_ => bail!("srv not set"),
};
let mut buf = vec![];
bincode_ops().serialize_into(&mut buf, msg).unwrap();
unsafe {
(srv.srv_handler)(srv.srv_data, buf.as_ptr(), buf.len());
(srv.srv_handler)(srv.srv_data, msg);
}
Ok(())
}