@@ -4,12 +4,15 @@ use bittorrent_http_tracker_core::container::HttpTrackerCoreContainer;
4
4
use bittorrent_primitives:: info_hash:: InfoHash ;
5
5
use bittorrent_tracker_core:: container:: TrackerCoreContainer ;
6
6
use futures:: executor:: block_on;
7
- use torrust_axum_http_tracker_server:: server:: { HttpServer , Launcher , Running , Stopped } ;
8
7
use torrust_axum_server:: tsl:: make_rust_tls;
9
8
use torrust_server_lib:: registar:: Registar ;
10
9
use torrust_tracker_configuration:: { logging, Configuration } ;
11
10
use torrust_tracker_primitives:: peer;
12
11
12
+ use crate :: server:: { HttpServer , Launcher , Running , Stopped } ;
13
+
14
+ pub type Started = Environment < Running > ;
15
+
13
16
pub struct Environment < S > {
14
17
pub container : Arc < EnvContainer > ,
15
18
pub registar : Registar ,
@@ -28,7 +31,11 @@ impl<S> Environment<S> {
28
31
}
29
32
30
33
impl Environment < Stopped > {
34
+ /// # Panics
35
+ ///
36
+ /// Will panic if it fails to make the TSL config from the configuration.
31
37
#[ allow( dead_code) ]
38
+ #[ must_use]
32
39
pub fn new ( configuration : & Arc < Configuration > ) -> Self {
33
40
initialize_global_services ( configuration) ;
34
41
@@ -50,6 +57,9 @@ impl Environment<Stopped> {
50
57
}
51
58
}
52
59
60
+ /// # Panics
61
+ ///
62
+ /// Will panic if the server fails to start.
53
63
#[ allow( dead_code) ]
54
64
pub async fn start ( self ) -> Environment < Running > {
55
65
Environment {
@@ -69,6 +79,9 @@ impl Environment<Running> {
69
79
Environment :: < Stopped > :: new ( configuration) . start ( ) . await
70
80
}
71
81
82
+ /// # Panics
83
+ ///
84
+ /// Will panic if the server fails to stop.
72
85
pub async fn stop ( self ) -> Environment < Stopped > {
73
86
Environment {
74
87
container : self . container ,
@@ -77,6 +90,7 @@ impl Environment<Running> {
77
90
}
78
91
}
79
92
93
+ #[ must_use]
80
94
pub fn bind_address ( & self ) -> & std:: net:: SocketAddr {
81
95
& self . server . state . binding
82
96
}
@@ -88,6 +102,10 @@ pub struct EnvContainer {
88
102
}
89
103
90
104
impl EnvContainer {
105
+ /// # Panics
106
+ ///
107
+ /// Will panic if the configuration is missing the HTTP tracker configuration.
108
+ #[ must_use]
91
109
pub fn initialize ( configuration : & Configuration ) -> Self {
92
110
let core_config = Arc :: new ( configuration. core . clone ( ) ) ;
93
111
let http_tracker_config = configuration
0 commit comments