pub trait CustomBinaryViewType: 'static + Sync {
type CustomBinaryView: CustomBinaryView;
const NAME: &'static str;
const LONG_NAME: &'static str = Self::NAME;
const DEPRECATED: bool = false;
const FORCE_LOADABLE: bool = false;
const HAS_NO_INITIAL_CONTENT: bool = false;
// Required methods
fn create_binary_view(
&self,
data: &BinaryView,
) -> Result<Self::CustomBinaryView, ()>;
fn is_valid_for(&self, data: &BinaryView) -> bool;
// Provided methods
fn create_binary_view_for_parse(
&self,
data: &BinaryView,
) -> Result<Self::CustomBinaryView, ()> { ... }
fn load_settings_for_data(&self, _data: &BinaryView) -> Ref<Settings> { ... }
}Expand description
Interface for creating custom binary views of a given type, analogous to BinaryViewType.
Required Associated Constants§
Provided Associated Constants§
Sourceconst LONG_NAME: &'static str = Self::NAME
const LONG_NAME: &'static str = Self::NAME
The longer name of the binary view type, defaults to CustomBinaryViewType::NAME.
Sourceconst DEPRECATED: bool = false
const DEPRECATED: bool = false
Is this CustomBinaryViewType deprecated and should not be used?
We specify this such that the view type may still be used by existing databases, but not newly created views.
Sourceconst FORCE_LOADABLE: bool = false
const FORCE_LOADABLE: bool = false
Is this CustomBinaryViewType able to be loaded forcefully?
If so, it will be shown in the drop-down when a user opens a file with options.
Sourceconst HAS_NO_INITIAL_CONTENT: bool = false
const HAS_NO_INITIAL_CONTENT: bool = false
Do instances of this CustomBinaryViewType 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 the previously saved view state for files not being loaded from a database, since a saved layout would reference content that isn’t available on reopening.
Required Associated Types§
Sourcetype CustomBinaryView: CustomBinaryView
type CustomBinaryView: CustomBinaryView
The associated BinaryViewBase for which this type creates with CustomBinaryViewType::create_binary_view.
Required Methods§
Sourcefn create_binary_view(
&self,
data: &BinaryView,
) -> Result<Self::CustomBinaryView, ()>
fn create_binary_view( &self, data: &BinaryView, ) -> Result<Self::CustomBinaryView, ()>
Constructs the custom binary view instance.
Sourcefn is_valid_for(&self, data: &BinaryView) -> bool
fn is_valid_for(&self, data: &BinaryView) -> bool
Is this BinaryViewType valid for the given the raw BinaryView?
Typical implementations will read the magic bytes (e.g. ‘MZ’), this is a performance-sensitive path so prefer inexpensive checks rather than comprehensive ones.
Provided Methods§
Sourcefn create_binary_view_for_parse(
&self,
data: &BinaryView,
) -> Result<Self::CustomBinaryView, ()>
fn create_binary_view_for_parse( &self, data: &BinaryView, ) -> Result<Self::CustomBinaryView, ()>
Constructs the custom binary view instance to be used for configuration.
This is the path that is used when opening a binary with “Open With Options”, and is what populates the sections and segments of the dialog along with settings like the image base (start) address.
The default implementation for this will construct a new instance identical to that of CustomBinaryViewType::create_binary_view.
Overriding this is encouraged as you can skip actually applying data to the view such as functions, symbols, and other data not required for configuration, especially because this binary view is created only temporarily and will be discarded after configuration is complete.
fn load_settings_for_data(&self, _data: &BinaryView) -> Ref<Settings>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.