@@ -12,13 +12,13 @@ use super::*;
1212use crate :: error:: * ;
1313use crate :: relay:: * ;
1414
15- // ManagerConfig a bag of config params for Manager.
15+ /// ` ManagerConfig` a bag of config params for ` Manager` .
1616pub struct ManagerConfig {
1717 pub relay_addr_generator : Box < dyn RelayAddressGenerator + Send + Sync > ,
1818 pub alloc_close_notify : Option < mpsc:: Sender < AllocationInfo > > ,
1919}
2020
21- // Manager is used to hold active allocations
21+ /// ` Manager` is used to hold active allocations.
2222pub struct Manager {
2323 allocations : AllocationMap ,
2424 reservations : Arc < Mutex < HashMap < String , u16 > > > ,
@@ -27,7 +27,7 @@ pub struct Manager {
2727}
2828
2929impl Manager {
30- // creates a new instance of Manager.
30+ /// Creates a new [` Manager`] .
3131 pub fn new ( config : ManagerConfig ) -> Self {
3232 Manager {
3333 allocations : Arc :: new ( Mutex :: new ( HashMap :: new ( ) ) ) ,
@@ -37,7 +37,7 @@ impl Manager {
3737 }
3838 }
3939
40- // Close closes the manager and closes all allocations it manages
40+ /// Closes this [` manager`] and closes all [`Allocation`]s it manages.
4141 pub async fn close ( & self ) -> Result < ( ) > {
4242 let allocations = self . allocations . lock ( ) . await ;
4343 for a in allocations. values ( ) {
@@ -46,8 +46,8 @@ impl Manager {
4646 Ok ( ( ) )
4747 }
4848
49- // Returns the information about the all [`Allocation`]s associated with
50- // the specified [`FiveTuple`]s.
49+ /// Returns the information about the all [`Allocation`]s associated with
50+ /// the specified [`FiveTuple`]s.
5151 pub async fn get_allocations_info (
5252 & self ,
5353 five_tuples : Option < Vec < FiveTuple > > ,
@@ -73,13 +73,13 @@ impl Manager {
7373 infos
7474 }
7575
76- // get_allocation fetches the allocation matching the passed FiveTuple
76+ /// Fetches the [`Allocation`] matching the passed [` FiveTuple`].
7777 pub async fn get_allocation ( & self , five_tuple : & FiveTuple ) -> Option < Arc < Allocation > > {
7878 let allocations = self . allocations . lock ( ) . await ;
7979 allocations. get ( five_tuple) . map ( Arc :: clone)
8080 }
8181
82- // create_allocation creates a new allocation and starts relaying
82+ /// Creates a new [`Allocation`] and starts relaying.
8383 pub async fn create_allocation (
8484 & self ,
8585 five_tuple : FiveTuple ,
@@ -123,7 +123,7 @@ impl Manager {
123123 Ok ( a)
124124 }
125125
126- // delete_allocation removes an allocation
126+ /// Removes an [`Allocation`].
127127 pub async fn delete_allocation ( & self , five_tuple : & FiveTuple ) {
128128 let allocation = self . allocations . lock ( ) . await . remove ( five_tuple) ;
129129
@@ -134,7 +134,7 @@ impl Manager {
134134 }
135135 }
136136
137- /// Deletes the [`Allocation`]s according to the specified ` username`.
137+ /// Deletes the [`Allocation`]s according to the specified username `name `.
138138 pub async fn delete_allocations_by_username ( & self , name : & str ) {
139139 let to_delete = {
140140 let mut allocations = self . allocations . lock ( ) . await ;
@@ -163,7 +163,7 @@ impl Manager {
163163 . await ;
164164 }
165165
166- // create_reservation stores the reservation for the token+port
166+ /// Stores the reservation for the token+port.
167167 pub async fn create_reservation ( & self , reservation_token : String , port : u16 ) {
168168 let reservations = Arc :: clone ( & self . reservations ) ;
169169 let reservation_token2 = reservation_token. clone ( ) ;
@@ -183,13 +183,13 @@ impl Manager {
183183 reservations. insert ( reservation_token, port) ;
184184 }
185185
186- // get_reservation returns the port for a given reservation if it exists
186+ /// Returns the port for a given reservation if it exists.
187187 pub async fn get_reservation ( & self , reservation_token : & str ) -> Option < u16 > {
188188 let reservations = self . reservations . lock ( ) . await ;
189189 reservations. get ( reservation_token) . copied ( )
190190 }
191191
192- // get_random_even_port returns a random un-allocated udp4 port
192+ /// Returns a random un-allocated udp4 port.
193193 pub async fn get_random_even_port ( & self ) -> Result < u16 > {
194194 let ( _, addr) = self . relay_addr_generator . allocate_conn ( true , 0 ) . await ?;
195195 Ok ( addr. port ( ) )
0 commit comments