Skip to main content

TypedOperation

Trait TypedOperation 

Source
pub trait TypedOperation: Operation {
    type Output: DeserializeOwned;
}
Expand description

A typed extension of Operation that declares a concrete output type.

Implement this alongside Operation when the step output has a known Rust type. Consumers can then deserialize the output without guessing the shape.

§Examples

use async_trait::async_trait;
use ironflow_core::operation::{Operation, OperationContext, TypedOperation};
use ironflow_core::error::OperationError;
use serde::Deserialize;
use serde_json::{Value, json};

#[derive(Debug, Deserialize)]
struct IssueCreated {
    iid: u64,
    url: String,
}

struct CreateIssue;

#[async_trait]
impl Operation for CreateIssue {
    fn kind(&self) -> &str { "gitlab" }
    async fn execute(&self, _ctx: &OperationContext) -> Result<Value, OperationError> {
        Ok(json!({"iid": 42, "url": "https://gitlab.com/issues/42"}))
    }
}

impl TypedOperation for CreateIssue {
    type Output = IssueCreated;
}

Required Associated Types§

Source

type Output: DeserializeOwned

The concrete output type that Operation::execute produces.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§