use std::collections::BTreeMap;
use std::future::Future;
use crate::ServerSpec;
use crate::runtime::metadata::HandlerMetadata;
use super::{AppInfo, RustStream, RustStreamError};
mod sealed {
pub trait Sealed {}
impl<L, St, PP> Sealed for super::RustStream<L, St, PP> {}
}
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 info(&self) -> &AppInfo;
fn servers(&self) -> &BTreeMap<String, ServerSpec>;
fn handlers(&self) -> &[HandlerMetadata];
}
#[allow(clippy::use_self)]
impl<L: Send, St: Send + Sync, PP: Send> App for RustStream<L, St, PP> {
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 info(&self) -> &AppInfo {
RustStream::info(self)
}
fn servers(&self) -> &BTreeMap<String, ServerSpec> {
RustStream::servers(self)
}
fn handlers(&self) -> &[HandlerMetadata] {
RustStream::handlers(self)
}
}