use std::collections::BTreeMap;
use std::future::Future;
use crate::ServerSpec;
use crate::runtime::metadata::HandlerMetadata;
use super::{AppInfo, RunningApp, RustStream, RustStreamError};
mod sealed {
pub trait Sealed {}
impl<Layers, State, Pipeline, Phase> Sealed for super::RustStream<Layers, State, Pipeline, Phase> {}
}
pub trait App: sealed::Sealed + Sized {
fn run(self) -> impl Future<Output = Result<(), RustStreamError>> + Send;
fn run_until<F>(self, shutdown: F) -> impl Future<Output = Result<(), RustStreamError>> + Send
where
F: Future<Output = ()> + Send;
fn start(self) -> impl Future<Output = Result<RunningApp, RustStreamError>> + Send;
fn info(&self) -> &AppInfo;
fn servers(&self) -> &BTreeMap<String, ServerSpec>;
fn handlers(&self) -> &[HandlerMetadata];
}
#[allow(clippy::use_self)]
impl<Layers: Send, State: Send + Sync + 'static, Pipeline: Send, Phase> App
for RustStream<Layers, State, Pipeline, Phase>
{
fn run(self) -> impl Future<Output = Result<(), RustStreamError>> + Send {
RustStream::run(self)
}
fn run_until<F>(self, shutdown: F) -> impl Future<Output = Result<(), RustStreamError>> + Send
where
F: Future<Output = ()> + Send,
{
RustStream::run_until(self, shutdown)
}
fn start(self) -> impl Future<Output = Result<RunningApp, RustStreamError>> + Send {
RustStream::start(self)
}
fn info(&self) -> &AppInfo {
RustStream::info(self)
}
fn servers(&self) -> &BTreeMap<String, ServerSpec> {
RustStream::servers(self)
}
fn handlers(&self) -> &[HandlerMetadata] {
RustStream::handlers(self)
}
}