Implement DataNotification for Rust#6543
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 |
3551171 to
b820e22
Compare
No description provided.