diff options
Diffstat (limited to 'rust/src/custom_binary_view.rs')
| -rw-r--r-- | rust/src/custom_binary_view.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/rust/src/custom_binary_view.rs b/rust/src/custom_binary_view.rs index 8c880fc1..84f39171 100644 --- a/rust/src/custom_binary_view.rs +++ b/rust/src/custom_binary_view.rs @@ -75,6 +75,16 @@ where }) } + extern "C" fn cb_has_no_initial_content<T>(ctxt: *mut c_void) -> bool + where + T: CustomBinaryViewType, + { + ffi_wrap!("BinaryViewTypeBase::has_no_initial_content", unsafe { + let view_type = &*(ctxt as *mut T); + view_type.has_no_initial_content() + }) + } + extern "C" fn cb_create<T>(ctxt: *mut c_void, data: *mut BNBinaryView) -> *mut BNBinaryView where T: CustomBinaryViewType, @@ -159,6 +169,7 @@ where isDeprecated: Some(cb_deprecated::<T>), isForceLoadable: Some(cb_force_loadable::<T>), getLoadSettingsForData: Some(cb_load_settings::<T>), + hasNoInitialContent: Some(cb_has_no_initial_content::<T>), }; unsafe { @@ -199,6 +210,17 @@ pub trait BinaryViewTypeBase: AsRef<BinaryViewType> { false } + /// Do instances of this [`BinaryViewType`] start with no loaded content? + /// + /// When true, the view has no meaningful default state: the user must make a + /// selection (e.g. load images from a shared cache) before any content exists. + /// Callers can use this to suppress restoring previously-saved view state for + /// files not being loaded from a database, since a saved layout would reference + /// content that isn't available on reopen. + fn has_no_initial_content(&self) -> bool { + false + } + fn default_load_settings_for_data(&self, data: &BinaryView) -> Option<Ref<Settings>> { let settings_handle = unsafe { BNGetBinaryViewDefaultLoadSettingsForData(self.as_ref().handle, data.handle) }; @@ -386,6 +408,10 @@ impl BinaryViewTypeBase for BinaryViewType { unsafe { BNIsBinaryViewTypeForceLoadable(self.handle) } } + fn has_no_initial_content(&self) -> bool { + unsafe { BNBinaryViewTypeHasNoInitialContent(self.handle) } + } + fn load_settings_for_data(&self, data: &BinaryView) -> Option<Ref<Settings>> { let settings_handle = unsafe { BNGetBinaryViewLoadSettingsForData(self.handle, data.handle) }; |
