From de23abd02ab27b6623656ed04e9b62d4dc1361b7 Mon Sep 17 00:00:00 2001 From: Rubens Brandao Date: Tue, 6 Aug 2024 10:45:49 -0300 Subject: [PATCH] Allow the user to modify the BV during initialization --- rust/examples/minidump/src/view.rs | 4 ++-- rust/src/custombinaryview.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rust/examples/minidump/src/view.rs b/rust/examples/minidump/src/view.rs index bbbe0bd5e..6ed419a94 100644 --- a/rust/examples/minidump/src/view.rs +++ b/rust/examples/minidump/src/view.rs @@ -392,7 +392,7 @@ unsafe impl CustomBinaryView for MinidumpBinaryView { Ok(MinidumpBinaryView::new(handle)) } - fn init(&self, _args: Self::Args) -> BinaryViewResult<()> { - self.init() + fn init(&mut self, _args: Self::Args) -> BinaryViewResult<()> { + MinidumpBinaryView::init(self) } } diff --git a/rust/src/custombinaryview.rs b/rust/src/custombinaryview.rs index 05f1acb8d..b930c7809 100644 --- a/rust/src/custombinaryview.rs +++ b/rust/src/custombinaryview.rs @@ -329,7 +329,7 @@ pub unsafe trait CustomBinaryView: 'static + BinaryViewBase + Sync + Sized { type Args: Send; fn new(handle: &BinaryView, args: &Self::Args) -> Result; - fn init(&self, args: Self::Args) -> Result<()>; + fn init(&mut self, args: Self::Args) -> Result<()>; } /// Represents a partially initialized custom `BinaryView` that should be returned to the core @@ -432,7 +432,7 @@ impl<'a, T: CustomBinaryViewType> CustomViewBuilder<'a, T> { match context .view - .assume_init_ref() + .assume_init_mut() .init(ptr::read(&context.args)) { Ok(_) => true,