CustomBinaryViewType

Trait CustomBinaryViewType 

Source
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§

Source

const NAME: &'static str

The name of the binary view type.

Provided Associated Constants§

Source

const LONG_NAME: &'static str = Self::NAME

The longer name of the binary view type, defaults to CustomBinaryViewType::NAME.

Source

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.

Source

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.

Source

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§

Required Methods§

Source

fn create_binary_view( &self, data: &BinaryView, ) -> Result<Self::CustomBinaryView, ()>

Constructs the custom binary view instance.

Source

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§

Source

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.

Source

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.

Implementors§