-
Notifications
You must be signed in to change notification settings - Fork 239
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
base: dev
Are you sure you want to change the base?
Conversation
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! |
When constructing the data notification it is very important that we not copy/clone the binaryninja-api/rust/src/data_notification.rs Lines 92 to 103 in ddad753
|
If I understand your comment correctly, then you are doing a pointer equality check during deregister? In that case a - let mut boxed_handle = Box::new(handle);
+ let mut boxed_handle = Box::pin(handle);
fn register_data_notification<'a, H: CustomDataNotification + 'a>(
view: &BinaryView,
notify: &'a H,
triggers: DataNotificationTriggers,
) -> DataNotificationHandle<'a, H> {}
fn register<'a>(
&'a self,
view: &BinaryView,
triggers: DataNotificationTriggers,
) -> DataNotificationHandle<'a, Self> where Self: 'a + Sized {
register_data_notification(view, self, triggers)
} if you require fn register_data_notification<'a, H: CustomDataNotification + 'a>(
view: &BinaryView,
notify: Pin<&'a H>,
triggers: DataNotificationTriggers,
) -> DataNotificationHandle<'a, H> {}
fn register<'a>(
self: Pin<&'a Self>,
view: &BinaryView,
triggers: DataNotificationTriggers,
) -> DataNotificationHandle<'a, Self> where Self: 'a + Sized {
register_data_notification(view, self, triggers)
} With a few extra lines you could then also support One alternative would be to add support for fetching the original |
Yea thanks for the correction, we want to pin the boxed value. Will make sure to swap out the call before merging. |
I can't see how the value could be moved leaving the original pointer invalid, specially because the Box is leaked immediately and only the type implementation itself will operate on the data ref. Let me know of an example where that can happen if you know some.
That's a really good idea, I did that in fact, the only difference is that
That will require a significant amount of complexity, I think that's better left for the user to implement manually, aka put the type in a |
No description provided.