-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
98 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use crate::engine::{EnginePlugin, PipelineContext, StepOutput}; | ||
use crate::error::EngineError; | ||
use crate::pipeline::runner::RecipientSelector; | ||
use crate::step::SerializedStep; | ||
use async_trait::async_trait; | ||
use serde::{Deserialize, Serialize}; | ||
use std::borrow::Cow; | ||
|
||
#[derive(Serialize, Deserialize)] | ||
#[serde(tag = "step")] | ||
pub enum Step { | ||
#[serde(rename = "core.set_recipient")] | ||
SetRecipient { recipient: RecipientSelector }, | ||
} | ||
|
||
pub const STEPS: &[&str] = &["core.set_recipient"]; | ||
|
||
struct CorePlugin {} | ||
|
||
#[async_trait] | ||
impl EnginePlugin for CorePlugin { | ||
async fn execute_step( | ||
&self, | ||
context: &mut PipelineContext, | ||
step: &SerializedStep, | ||
) -> Result<StepOutput, EngineError> { | ||
let step: Step = step.clone().convert_step()?; | ||
|
||
match step { | ||
Step::SetRecipient { recipient } => { | ||
let recipient = match recipient { | ||
RecipientSelector::Recipient(r) => r, | ||
}; | ||
context.recipient = Some(recipient); | ||
Ok(StepOutput::Continue) | ||
} | ||
} | ||
} | ||
|
||
fn steps(&self) -> Vec<Cow<'static, str>> { | ||
STEPS.iter().map(|&s| s.into()).collect() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters