pub trait Operation: Send + Sync {
// Required methods
fn kind(&self) -> &str;
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 OperationContext,
) -> Pin<Box<dyn Future<Output = Result<Value, OperationError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
// Provided method
fn input(&self) -> Option<Value> { ... }
}Expand description
A user-defined operation that integrates into the workflow step lifecycle.
Implement this trait for custom integrations (GitLab, Gmail, Slack, etc.)
that need full step tracking when executed via WorkflowContext::operation().
§Contract
kind()returns a short, lowercase identifier stored asStepKind::Customin the database (e.g."gitlab","gmail","slack").execute()performs the operation and returns a JSONValueon success. The engine persists this as the step output.
§Examples
use async_trait::async_trait;
use ironflow_core::operation::{Operation, OperationContext};
use ironflow_core::error::OperationError;
use serde_json::{Value, json};
struct SendSlackMessage {
channel: String,
text: String,
}
#[async_trait]
impl Operation for SendSlackMessage {
fn kind(&self) -> &str { "slack" }
async fn execute(&self, ctx: &OperationContext) -> Result<Value, OperationError> {
// Post to Slack API using ctx.http_client() ...
Ok(json!({"ok": true, "ts": "1234567890.123456"}))
}
}Required Methods§
Sourcefn kind(&self) -> &str
fn kind(&self) -> &str
A short, lowercase identifier for this operation type.
Stored as StepKind::Custom(kind) in the database.
Examples: "gitlab", "gmail", "slack".
Sourcefn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 OperationContext,
) -> Pin<Box<dyn Future<Output = Result<Value, OperationError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 OperationContext,
) -> Pin<Box<dyn Future<Output = Result<Value, OperationError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Execute the operation and return the result as JSON.
The returned Value is persisted as the step output. On error,
the engine marks the step as Failed and records the error message.
§Errors
Return OperationError if the operation fails.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".