shepherd-rs 0.2.0

Shepherd is a resilient, non-blocking orchestrator that persistently transforms and delivers data—built for remote, compute-heavy workloads.
Documentation
//! # Transform Request Trait
//!
//! This trait defines the behavior of transformation requests in the
//! shepherd framework.
//!
//! ## Overview
//! - **TransformRequest**: Represents a request to transform input data into
//!   output data.
//! - **Identifier**: Provides unique identifiers for tracking requests.
//!
//! ## Example
//! ```rust
//! struct MyTransformRequest;
//!
//! impl TransformRequest for MyTransformRequest {
//!     // Implementation details...
//! }
//! ```

use std::fmt::Debug;

/// A trait representing a transformation request in shepherd-rs processing
/// system. Each transformation request is a request to transform some input
/// data into an output format. As such, the `Input` and `Output` types are
/// generic, associated types allowing for flexibility in the types of data
/// being transformed.
pub trait TransformRequest: Send + Sync + Debug + Clone {
    /// A unique identifier for the transformation request.
    /// This needs to be unique across all transformation requests,
    /// across different shepherd-rs instances (process failures, etc.).
    type Identifier: Send + Sync + Eq + Debug;

    /// The type of the input for the transformation.
    type Input: Send + Clone;

    /// The type of the output expected after the transformation.
    type Output: Send + Clone;

    /// Returns the unique identifier for the transformation request.
    fn request_id(&self) -> Self::Identifier;

    /// Returns the input for the transformation request.
    fn input(&self) -> &Self::Input;

    /// Given the TransformRequest is the latest in the stream,
    /// what dynamic configs need to be updated, Key is always a
    /// string, value is always a `Vec<u8>` representing the serialized
    /// value
    fn get_dyn_configs(&self) -> Vec<(String, Vec<u8>)>;
}

#[cfg(test)]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct NilTR;

#[cfg(test)]
impl TransformRequest for NilTR {
    type Identifier = ();
    type Input = ();
    type Output = ();

    fn request_id(&self) -> Self::Identifier { () }

    fn input(&self) -> &Self::Input { &() }

    fn get_dyn_configs(&self) -> Vec<(String, Vec<u8>)> { vec![] }
}