Skip to content

Implement DataNotification for rust #6543

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

rbran
Copy link
Contributor

@rbran rbran commented Apr 1, 2025

No description provided.

@emesare
Copy link
Member

emesare commented Apr 1, 2025

The solution for only registering the notifications is fine with me, I will be able to review this more once testing is done for the upcoming 5.0 release. Thank you!

@emesare emesare self-requested a review April 1, 2025 15:07
@emesare emesare added this to the H milestone Apr 1, 2025
@emesare emesare added the Component: Rust API Issue needs changes to the Rust API label Apr 1, 2025
@emesare emesare linked an issue Apr 17, 2025 that may be closed by this pull request
@emesare emesare self-assigned this Apr 18, 2025
@emesare
Copy link
Member

emesare commented Apr 25, 2025

When constructing the data notification it is very important that we not copy/clone the BNBinaryDataNotification otherwise when we go to unregister the notifications we will be keying off a different object. I understand this is more of an issue with the FFI layer keying off something such as the pointer value but we should still support unregistering it. In the branch below I just wrap the BNBinaryDataNotification constructed in register_data_notification with a Box and move the boxed value into the returned DataNotificationHandle.

let handle = BNBinaryDataNotification {
context: leak_notify as *mut _ as *mut c_void,
$($ffi_param_name: triggers.$fun_name.then_some($fun_name::<H>)),*
};
// Box it to prevent a copy being returned in `DataNotificationHandle`.
let mut boxed_handle = Box::new(handle);
unsafe { BNRegisterDataNotification(view.handle, boxed_handle.as_mut()) };
DataNotificationHandle {
bv: view.to_owned(),
handle: boxed_handle,
_life: std::marker::PhantomData,
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Rust API Issue needs changes to the Rust API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Map out data notifications in the rust api
2 participants