flashbang/server/runtime/
mod.rs1use std::{io, sync::{Arc, Mutex, atomic::AtomicBool}, task::{Poll, Waker}, time::{Instant, Duration}, net::SocketAddr};
2
3use std::future::Future;
4
5use bytes::Bytes;
6
7use super::config::ServerConfig;
8
9pub mod tokio_server;
10
11pub const INSECURE_PORT: u16 = 3478;
13
14pub const SECURE_PORT: u16 = 5349;
16
17#[derive(Clone)]
18pub struct ServerRunner {
19 pub running: Arc<AtomicBool>,
20 pub config: ServerConfig,
21}
22
23#[async_trait::async_trait]
24pub trait ServerRuntime: Send + Sync {
25 async fn run(runner: ServerRunner);
26}
27
28#[async_trait::async_trait]
29pub trait ServerConn {
30 async fn send(&mut self, buf: &[u8], addr: SocketAddr) -> io::Result<()>;
31
32 async fn recv(&mut self) -> io::Result<(Bytes, SocketAddr)>;
33}
34
35pub struct ServerProcessor<T: ServerConn> {
36 conn: T,
37}
38
39impl<T: ServerConn> ServerProcessor<T> {
40 pub fn new(conn: T) -> Self {
41 Self {
42 conn
43 }
44 }
45
46 pub fn process(&self) {
47
48 }
49}