1use std::marker::PhantomData;
2use std::sync::{Arc, atomic::AtomicBool};
3
4use self::config::ServerConfig;
5use self::runtime::{ServerRuntime, ServerRunner};
6
7pub mod config;
8pub mod runtime;
9
10#[derive(Default)]
14pub struct Server<R: ServerRuntime> {
15 running: Arc<AtomicBool>,
16 config: ServerConfig,
17 _marker: PhantomData<R>,
18}
19
20impl<R: ServerRuntime> Server<R> {
21 pub fn new(running: Arc<AtomicBool>, config: ServerConfig) -> Self {
22 Self {
23 running,
24 config,
25 _marker: PhantomData,
26 }
27 }
28
29 pub async fn run(&mut self) {
30 let runner = ServerRunner {
31 running: self.running.clone(),
32 config: self.config,
33 };
34
35 R::run(runner).await;
36 }
37}