pub struct CreatePipelineUseCase { /* private fields */ }Expand description
Use case for creating new processing pipelines.
This use case handles the complete workflow for creating a new pipeline, including name validation, stage parsing, configuration setup, and persistence to the repository.
§Responsibilities
- Validate and normalize pipeline name
- Parse stage specifications from comma-separated string
- Map stage names to types and algorithms
- Create pipeline domain entity
- Save pipeline to repository
- Handle creation errors gracefully
§Dependencies
- Pipeline Repository: For persisting pipeline data
§Example
ⓘ
let use_case = CreatePipelineUseCase::new(pipeline_repository);
match use_case.execute(
"data-backup".to_string(),
"brotli,aes256gcm".to_string(),
None,
).await {
Ok(()) => println!("Pipeline created successfully"),
Err(e) => eprintln!("Failed to create pipeline: {}", e),
}Implementations§
Source§impl CreatePipelineUseCase
impl CreatePipelineUseCase
Sourcepub fn new(pipeline_repository: Arc<SqlitePipelineRepository>) -> Self
pub fn new(pipeline_repository: Arc<SqlitePipelineRepository>) -> Self
Sourcepub async fn execute(
&self,
name: String,
stages: String,
output: Option<PathBuf>,
) -> Result<()>
pub async fn execute( &self, name: String, stages: String, output: Option<PathBuf>, ) -> Result<()>
Executes the create pipeline use case.
Creates a new pipeline with the specified name and stages, validates the configuration, and persists it to the repository.
§Parameters
name- Pipeline name (will be normalized to kebab-case)stages- Comma-separated list of stage specifications- Examples: “brotli”, “brotli,aes256gcm”, “compression,encryption,checksum”
output- Optional file path for pipeline configuration export (not yet implemented)
§Stage Specifications
Generic Types (use default algorithms):
compression→ brotliencryption→ aes256gcmchecksum→ sha256passthrough→ no-op
Specific Algorithms:
- Compression:
brotli,gzip,zstd,lz4 - Encryption:
aes256gcm,aes128gcm,chacha20poly1305 - Transform:
base64,pii_masking,tee,debug
Type:Algorithm Syntax:
compression:lz4encryption:chacha20poly1305
§Returns
Ok(())- Pipeline created and saved successfullyErr(anyhow::Error)- Validation or persistence failed
§Errors
Returns errors for:
- Empty pipeline name
- Name less than 4 characters after normalization
- Reserved pipeline names
- Invalid stage specifications
- Repository save failures
- Database connection errors
§Example
ⓘ
// Create simple compression pipeline
use_case.execute("backup".to_string(), "brotli".to_string(), None).await?;
// Create secure multi-stage pipeline
use_case.execute(
"Secure Backup!".to_string(), // Will be normalized to "secure-backup"
"brotli,aes256gcm,checksum".to_string(),
None,
).await?;Auto Trait Implementations§
impl Freeze for CreatePipelineUseCase
impl !RefUnwindSafe for CreatePipelineUseCase
impl Send for CreatePipelineUseCase
impl Sync for CreatePipelineUseCase
impl Unpin for CreatePipelineUseCase
impl !UnwindSafe for CreatePipelineUseCase
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more