pub trait NodeProcessor {
// Required methods
fn name(&self) -> &str;
fn process(
&self,
input: NodeInput,
progress: &ProgressReporter,
ctx: &dyn ProcessContext,
) -> Result<NodeOutput, BntoError>;
// Provided methods
fn validate(&self, _params: &Map<String, Value>) -> Vec<String> { ... }
fn process_batch(
&self,
input: BatchInput,
progress: &ProgressReporter,
ctx: &dyn ProcessContext,
) -> Result<NodeOutput, BntoError> { ... }
fn metadata(&self) -> NodeMetadata { ... }
}Expand description
The contract that every node type must implement.
Currently synchronous – async is handled at the Web Worker level. wasm-bindgen doesn’t support async trait methods across the WASM boundary.
Required Methods§
Sourcefn name(&self) -> &str
fn name(&self) -> &str
The unique name of this node type (e.g., “compress-images”). Used for logging and progress reporting.
Sourcefn process(
&self,
input: NodeInput,
progress: &ProgressReporter,
ctx: &dyn ProcessContext,
) -> Result<NodeOutput, BntoError>
fn process( &self, input: NodeInput, progress: &ProgressReporter, ctx: &dyn ProcessContext, ) -> Result<NodeOutput, BntoError>
Process a single input file and produce output.
Arguments:
&self— reference to the node processor instanceinput— the file data, filename, MIME type, and config paramsprogress— callback to report progress to the UI (0-100%)ctx— system access boundary (commands, temp files, env vars)
Returns:
Ok(NodeOutput)— processing succeeded, here are the resultsErr(BntoError)— processing failed, here’s what went wrong
Provided Methods§
Sourcefn validate(&self, _params: &Map<String, Value>) -> Vec<String>
fn validate(&self, _params: &Map<String, Value>) -> Vec<String>
Validate the input parameters before processing.
This is called BEFORE process() to catch configuration errors
early (missing required params, invalid values, etc.) without
doing any expensive file processing.
Returns a list of validation errors (empty = valid).
Default implementation passes validation. Override in specific node types to add parameter validation.
Sourcefn process_batch(
&self,
input: BatchInput,
progress: &ProgressReporter,
ctx: &dyn ProcessContext,
) -> Result<NodeOutput, BntoError>
fn process_batch( &self, input: BatchInput, progress: &ProgressReporter, ctx: &dyn ProcessContext, ) -> Result<NodeOutput, BntoError>
Process a batch of files together, producing combined output.
Override this for processors with InputCardinality::Batch (merge, zip,
concat). The default falls back to calling process() per file and
concatenating results — suitable for PerFile processors.
Sourcefn metadata(&self) -> NodeMetadata
fn metadata(&self) -> NodeMetadata
Return the processor’s self-describing metadata.
This tells consumers everything about this processor: what it’s called, what category it belongs to, what parameters it accepts, what files it handles, and whether it runs in the browser.
Every concrete processor SHOULD override this with its real metadata. The default returns a placeholder “unknown” metadata — useful for tests and mocks that don’t need real metadata.