tray_wrapper/server_generator.rs
1use std::{pin::Pin, sync::Arc};
2
3/// This is the core of the library, in short you need to supply a function that
4/// when called returns async futures that can be polled.
5pub type ServerGenerator = Arc<dyn Fn() -> ServerGeneratorResult + Send + Sync>;
6
7/// This is the return type for the async tasks, the future's return type is to indicate
8/// to the wrapper if it should keep being executed.
9pub type ServerGeneratorResult = Pin<Box<dyn Future<Output = ContinueRunning> + Send>>;
10
11/// The various options on if it should continue to execute the server again.
12pub enum ContinueRunning {
13 /// The server generator should be called again
14 Continue,
15 /// There is no point in trying to execute again
16 Exit,
17 /// There is no point in trying to execute again and we have a reason
18 ExitWithError(String),
19}