pub trait Operation: Send + Sync {
// Required methods
fn kind(&self) -> &str;
fn execute<'a>(
&'a self,
ctx: &'a OperationContext,
) -> Pin<Box<dyn Future<Output = Result<Value, OperationError>> + Send + 'a>>;
// 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 ironflow_core::operation::{Operation, OperationContext};
use ironflow_core::error::OperationError;
use serde_json::{Value, json};
use std::future::Future;
use std::pin::Pin;
struct SendSlackMessage {
channel: String,
text: String,
}
impl Operation for SendSlackMessage {
fn kind(&self) -> &str { "slack" }
fn execute<'a>(
&'a self,
ctx: &'a OperationContext,
) -> Pin<Box<dyn Future<Output = Result<Value, OperationError>> + Send + 'a>> {
Box::pin(async move {
// 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<'a>(
&'a self,
ctx: &'a OperationContext,
) -> Pin<Box<dyn Future<Output = Result<Value, OperationError>> + Send + 'a>>
fn execute<'a>( &'a self, ctx: &'a OperationContext, ) -> Pin<Box<dyn Future<Output = Result<Value, OperationError>> + Send + 'a>>
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".