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
impl TransformContext
Sourcepub fn input(&self) -> Ref<BinaryView>
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.
Sourcepub fn name(&self) -> String
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.
Sourcepub fn available_transforms(&self) -> Array<BnString>
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.
Sourcepub fn transform_name(&self) -> String
pub fn transform_name(&self) -> String
The name of the transform that created this context.
Sourcepub fn set_transform_name(&self, transform_name: &str)
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.
pub fn set_transform_params(&self, params: &TransformInputParameters)
pub fn set_transform_param(&self, name: &str, value: &DataBuffer)
pub fn has_transform_param(&self, name: &str) -> bool
pub fn clear_transform_params(&self, name: &str)
Sourcepub fn extraction_message(&self) -> String
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.
Sourcepub fn extraction_result(&self) -> TransformResult
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.
Sourcepub fn transform_result(&self) -> TransformResult
pub fn transform_result(&self) -> TransformResult
The result of applying the transform to the current input.
Can be set with TransformContext::set_transform_result.
Sourcepub fn set_transform_result(&self, result: TransformResult)
pub fn set_transform_result(&self, result: TransformResult)
Set the result of the applied transform on the current input.
Sourcepub fn metadata(&self) -> Ref<Metadata>
pub fn metadata(&self) -> Ref<Metadata>
Metadata associated with this context.
Can be accessed by transforms to store format-specific information.
Sourcepub fn parent(&self) -> Option<Ref<TransformContext>>
pub fn parent(&self) -> Option<Ref<TransformContext>>
The parent context will be None if the context is the root context.
pub fn children(&self) -> Array<TransformContext>
pub fn child_by_name(&self, name: &str) -> Option<Ref<TransformContext>>
Sourcepub fn create_child(
&self,
name: &str,
data: &DataBuffer,
extraction_result: TransformResult,
extraction_message: &str,
is_descriptor: bool,
) -> Ref<TransformContext>
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’).
Sourcepub fn is_root(&self) -> bool
pub fn is_root(&self) -> bool
This context is the root of the transform session, it has no parent.
Sourcepub fn available_files(&self) -> Array<BnString>
pub fn available_files(&self) -> Array<BnString>
The list of available files for extraction.
Sourcepub fn set_available_files(&self, files: &[&str])
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.
Sourcepub fn requested_files(&self) -> Array<BnString>
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.
Sourcepub fn set_requested_files(&self, files: &[&str])
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.
Sourcepub fn is_database(&self) -> bool
pub fn is_database(&self) -> bool
If the contents of this context represent a database file (BNDB).
Sourcepub fn is_interactive(&self) -> bool
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.