mirror of
https://github.com/logos-messaging/logos-messaging-rust-bindings.git
synced 2026-04-04 11:03:12 +00:00
chore: update ffi
This commit is contained in:
parent
24df1cb939
commit
419cf193a9
@ -46,6 +46,7 @@ async fn main() -> Result<(), Error> {
|
||||
WakuEvent::ConnectionChange(_evt) => {
|
||||
// dbg!("Conn change evt", evt);
|
||||
}
|
||||
WakuEvent::NodeHealthChange(_evt) => {}
|
||||
WakuEvent::Unrecognized(err) => panic!("Unrecognized waku event: {:?}", err),
|
||||
_ => panic!("event case not expected"),
|
||||
};
|
||||
@ -75,6 +76,7 @@ async fn main() -> Result<(), Error> {
|
||||
WakuEvent::ConnectionChange(_evt) => {
|
||||
// dbg!("Conn change evt", evt);
|
||||
}
|
||||
WakuEvent::NodeHealthChange(_evt) => {}
|
||||
WakuEvent::Unrecognized(err) => panic!("Unrecognized waku event: {:?}", err),
|
||||
_ => panic!("event case not expected"),
|
||||
};
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
use crate::general::libwaku_response::LibwakuResponse;
|
||||
|
||||
use std::{slice, str};
|
||||
use waku_sys::WakuCallBack;
|
||||
use waku_sys::FFICallBack;
|
||||
|
||||
unsafe extern "C" fn trampoline<F>(
|
||||
ret_code: ::std::os::raw::c_int,
|
||||
@ -26,7 +26,7 @@ unsafe extern "C" fn trampoline<F>(
|
||||
closure(result);
|
||||
}
|
||||
|
||||
pub fn get_trampoline<F>(_closure: &F) -> WakuCallBack
|
||||
pub fn get_trampoline<F>(_closure: &F) -> FFICallBack
|
||||
where
|
||||
F: FnMut(LibwakuResponse),
|
||||
{
|
||||
@ -57,10 +57,10 @@ macro_rules! handle_ffi_call {
|
||||
let code = unsafe {
|
||||
let cb = get_trampoline(&closure);
|
||||
$waku_fn(
|
||||
$ctx, // Pass the context
|
||||
$($($arg),*,)? // Expand the variadic arguments if provided
|
||||
cb, // Pass the callback trampoline
|
||||
&mut closure as *mut _ as *mut c_void
|
||||
$ctx, // Pass the context
|
||||
cb, // Pass the callback trampoline
|
||||
&mut closure as *mut _ as *mut c_void, // Pass the user data
|
||||
$($($arg),*)? // Expand the variadic arguments if provided
|
||||
)
|
||||
};
|
||||
|
||||
|
||||
@ -28,7 +28,7 @@ pub struct WakuNodeConfig {
|
||||
#[default(Some(true))]
|
||||
pub relay: Option<bool>,
|
||||
pub relay_topics: Vec<String>,
|
||||
#[default(vec![1])]
|
||||
#[default(vec![0])]
|
||||
pub shards: Vec<usize>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub max_message_size: Option<String>,
|
||||
|
||||
@ -49,7 +49,7 @@ impl WakuNodeContext {
|
||||
*boxed_closure = Box::new(closure);
|
||||
unsafe {
|
||||
let cb = get_trampoline(&(*boxed_closure));
|
||||
waku_sys::waku_set_event_callback(
|
||||
waku_sys::set_event_callback(
|
||||
self.obj_ptr,
|
||||
cb,
|
||||
&mut (*boxed_closure) as *mut _ as *mut c_void,
|
||||
|
||||
@ -27,6 +27,9 @@ pub enum WakuEvent {
|
||||
#[serde(rename = "connection_change")]
|
||||
ConnectionChange(ConnectionChangeEvent),
|
||||
|
||||
#[serde(rename = "node_health_change")]
|
||||
NodeHealthChange(NodeHealthChangeEvent),
|
||||
|
||||
Unrecognized(serde_json::Value),
|
||||
}
|
||||
|
||||
@ -56,12 +59,17 @@ pub struct TopicHealthEvent {
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ConnectionChangeEvent {
|
||||
/// The pubsub topic on which the message was received
|
||||
pub peer_id: String,
|
||||
/// The message hash
|
||||
pub peer_event: String,
|
||||
}
|
||||
|
||||
/// Type of `event` field for a `node_health_change` event
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct NodeHealthChangeEvent {
|
||||
pub status: String,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::WakuEvent;
|
||||
|
||||
@ -117,6 +117,8 @@ fn generate_bindgen_code(project_dir: &Path) {
|
||||
|
||||
println!("cargo:rustc-link-lib=dl");
|
||||
println!("cargo:rustc-link-lib=m");
|
||||
// nim-lsquic embeds BoringSSL (C++) — requires C++ runtime
|
||||
println!("cargo:rustc-link-lib=c++");
|
||||
|
||||
println!(
|
||||
"cargo:rustc-link-search=native={}",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user