saddle-core 0.1.0

Shared contracts for Saddle components
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::{future::Future, pin::Pin};

use crate::Result;

pub type LifecycleFuture<'a> = Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>;

/// Object-safe lifecycle contract used by the Saddle application assembler.
///
/// Implementations must be safe to start once and shut down once. Ordering and
/// graceful-drain policy belong to `saddle-runtime`, not this contract.
pub trait ComponentLifecycle: Send + Sync {
    fn name(&self) -> &'static str;

    fn start(&self) -> LifecycleFuture<'_>;

    fn shutdown(&self) -> LifecycleFuture<'_>;
}