TransformContext

Struct TransformContext 

Source
pub struct TransformContext { /* private fields */ }
Expand description

A TransformContext represents a node in the transform tree, for use in a TransformSession.

Implementations§

Source§

impl TransformContext

Source

pub fn input(&self) -> Ref<BinaryView>

The BinaryView that this context is associated with.

This contains the data that is to be processed by the selected transform.

Source

pub fn name(&self) -> String

The name associated with this context, typically the name of the file in the case of a container like zip or archive.

Source

pub fn available_transforms(&self) -> Array<BnString>

A list of transforms that can be used to process this context.

The list of available transforms is gathered by checking Transform::can_decode on all the registered transforms.

Source

pub fn transform_name(&self) -> String

The name of the transform that created this context.

Source

pub fn set_transform_name(&self, transform_name: &str)

Override the Transform used to process this context.

This is used when automatically selecting a transform is not possible (e.g. no magic bytes) or when there is multiple conflicting transforms.

After setting the transform name, process the context with TransformSession::process_from.

Source

pub fn set_transform_params(&self, params: &TransformInputParameters)

Source

pub fn set_transform_param(&self, name: &str, value: &DataBuffer)

Source

pub fn has_transform_param(&self, name: &str) -> bool

Source

pub fn clear_transform_params(&self, name: &str)

Source

pub fn extraction_message(&self) -> String

The message associated with the extraction operation performed by the parent.

Originates from a call to TransformContext::create_child.

Source

pub fn extraction_result(&self) -> TransformResult

The result associated with the extraction operation performed by the parent.

Originates from a call to TransformContext::create_child.

Source

pub fn transform_result(&self) -> TransformResult

The result of applying the transform to the current input.

Can be set with TransformContext::set_transform_result.

Source

pub fn set_transform_result(&self, result: TransformResult)

Set the result of the applied transform on the current input.

Source

pub fn metadata(&self) -> Ref<Metadata>

Metadata associated with this context.

Can be accessed by transforms to store format-specific information.

Source

pub fn parent(&self) -> Option<Ref<TransformContext>>

The parent context will be None if the context is the root context.

Source

pub fn children(&self) -> Array<TransformContext>

Source

pub fn child_by_name(&self, name: &str) -> Option<Ref<TransformContext>>

Source

pub fn create_child( &self, name: &str, data: &DataBuffer, extraction_result: TransformResult, extraction_message: &str, is_descriptor: bool, ) -> Ref<TransformContext>

Create a new child context with the given data.

The child context will be added as a child of this context.

  • data: The contents of the child context.
  • extraction_result: The result of the extraction operation.
  • extraction_message: The message associated with the extraction operation.
  • is_descriptor: Indicates whether the child context represents a descriptor, if so, the name of the child context when shown will show both the parent name and then the child name (‘parent.child’).
Source

pub fn is_leaf(&self) -> bool

This context has no children.

Source

pub fn is_root(&self) -> bool

This context is the root of the transform session, it has no parent.

Source

pub fn available_files(&self) -> Array<BnString>

The list of available files for extraction.

Source

pub fn set_available_files(&self, files: &[&str])

Set the list of available files available for extraction.

A Transform will call this to set the files that are possible to extract, but this won’t actually mark the files for extraction by the TransformSession. To mark files for extraction, call TransformContext::set_requested_files after calling this function.

Source

pub fn requested_files(&self) -> Array<BnString>

The files with which to extract from this context.

This is used in TransformSession::process_from to actually perform the extraction of the child contexts.

Source

pub fn set_requested_files(&self, files: &[&str])

Specify which files to extract from this context. The associated TransformSession will then extract the specified files with TransformSession::process_from.

To get the list of possible files, use TransformContext::available_files.

Source

pub fn is_database(&self) -> bool

If the contents of this context represent a database file (BNDB).

Source

pub fn is_interactive(&self) -> bool

If this context is being used interactively.

Transforms can use this to adjust their behavior. For example, filtering children in non-interactive mode while showing all children in interactive mode.

Source

pub fn settings(&self) -> Ref<Settings>

Trait Implementations§

Source§

impl CoreArrayProvider for TransformContext

Source§

impl ToOwned for TransformContext

Source§

type Owned = Ref<TransformContext>

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> Self::Owned

Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · Source§

fn clone_into(&self, target: &mut Self::Owned)

Uses borrowed data to replace owned data, usually by cloning. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more