diff options
| author | Glenn Smith <glenn@vector35.com> | 2023-06-08 17:15:51 -0400 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2023-09-20 16:24:13 -0400 |
| commit | 1299153666110369829676107128448985693716 (patch) | |
| tree | b0d638e6a26497136fad19fc8809d164623f5d4b /rust/src/custombinaryview.rs | |
| parent | 3a8e0c4478dde202fff9258824536793498736c2 (diff) | |
Rust API: Fix load settings not being the right load settings
There is a distinction between *default* load settings and just load settings. Rust did not have this distinction and was using the default settings for a function that was not labelled default.
Diffstat (limited to 'rust/src/custombinaryview.rs')
| -rw-r--r-- | rust/src/custombinaryview.rs | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/rust/src/custombinaryview.rs b/rust/src/custombinaryview.rs index 740d0f40..2fd37cab 100644 --- a/rust/src/custombinaryview.rs +++ b/rust/src/custombinaryview.rs @@ -157,7 +157,7 @@ pub trait BinaryViewTypeBase: AsRef<BinaryViewType> { fn is_deprecated(&self) -> bool; - fn load_settings_for_data(&self, data: &BinaryView) -> Result<Ref<Settings>> { + fn default_load_settings_for_data(&self, data: &BinaryView) -> Result<Ref<Settings>> { let settings_handle = unsafe { BNGetBinaryViewDefaultLoadSettingsForData(self.as_ref().0, data.handle) }; @@ -167,6 +167,17 @@ pub trait BinaryViewTypeBase: AsRef<BinaryViewType> { unsafe { Ok(Settings::from_raw(settings_handle)) } } } + + fn load_settings_for_data(&self, data: &BinaryView) -> Result<Ref<Settings>> { + let settings_handle = + unsafe { BNGetBinaryViewLoadSettingsForData(self.as_ref().0, data.handle) }; + + if settings_handle.is_null() { + Err(()) + } else { + unsafe { Ok(Settings::from_raw(settings_handle)) } + } + } } pub trait BinaryViewTypeExt: BinaryViewTypeBase { @@ -253,7 +264,7 @@ impl BinaryViewTypeBase for BinaryViewType { unsafe { BNIsBinaryViewTypeDeprecated(self.0) } } - fn load_settings_for_data(&self, data: &BinaryView) -> Result<Ref<Settings>> { + fn default_load_settings_for_data(&self, data: &BinaryView) -> Result<Ref<Settings>> { let settings_handle = unsafe { BNGetBinaryViewDefaultLoadSettingsForData(self.0, data.handle) }; @@ -263,6 +274,16 @@ impl BinaryViewTypeBase for BinaryViewType { unsafe { Ok(Settings::from_raw(settings_handle)) } } } + + fn load_settings_for_data(&self, data: &BinaryView) -> Result<Ref<Settings>> { + let settings_handle = unsafe { BNGetBinaryViewLoadSettingsForData(self.0, data.handle) }; + + if settings_handle.is_null() { + Err(()) + } else { + unsafe { Ok(Settings::from_raw(settings_handle)) } + } + } } impl CoreArrayProvider for BinaryViewType { |
