1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
use crate::app::App; use crate::core::context::Context; use crate::core::request::RequestWithParams; use async_trait::async_trait; #[async_trait] pub trait ThrusterServer { type Context: Context + Send; type Response: Send; type Request: RequestWithParams + Send; type State: Send; fn new(_: App<Self::Request, Self::Context, Self::State>) -> Self; async fn build(self, host: &str, port: u16); fn start(self, host: &str, port: u16) where Self: Sized, { tokio::runtime::Runtime::new() .unwrap() .block_on(self.build(host, port)) } }