@@ -155,7 +155,7 @@ impl From<quinn::ClosedStream> for AcceptError {
155
155
#[ derive( Debug , Snafu ) ]
156
156
#[ non_exhaustive]
157
157
pub enum RouterError {
158
- #[ snafu( display( "The router actor closed" ) ) ]
158
+ #[ snafu( display( "Endpoint closed" ) ) ]
159
159
Closed { } ,
160
160
}
161
161
@@ -164,7 +164,7 @@ pub enum RouterError {
164
164
#[ snafu( module) ]
165
165
#[ non_exhaustive]
166
166
pub enum StopAcceptingError {
167
- #[ snafu( display( "The router actor closed" ) ) ]
167
+ #[ snafu( display( "Endpoint closed" ) ) ]
168
168
Closed { } ,
169
169
#[ snafu( display( "The ALPN requested to be removed is not registered" ) ) ]
170
170
UnknownAlpn { } ,
@@ -381,16 +381,15 @@ impl Router {
381
381
self . cancel_token . is_cancelled ( )
382
382
}
383
383
384
- /// Adds a protocol to the list of accepted protocols .
384
+ /// Accepts incoming connections with this `alpn` via [`ProtocolHandler`] .
385
385
///
386
- /// Configures the router to accept the [`ProtocolHandler`] when receiving a connection
387
- /// with this `alpn `.
386
+ /// After this function returns, new connections with this `alpn` will be handled
387
+ /// by the passed `handler `.
388
388
///
389
- /// Once the function yields, new connections with this `alpn` will be handled.
390
- ///
391
- /// If a protocol handler was already registered for `alpn`, the previous handler will be shutdown.
392
- ///
393
- /// Returns `true` if
389
+ /// If a protocol handler was already registered for `alpn`, the previous handler will be
390
+ /// shutdown. Existing connections will not be aborted by the router, but some protocol
391
+ /// handlers may abort existing connnections in their [`Router::shutdown`] implementation.
392
+ /// Consult the documentation of the protocol handler to see if that is the case.
394
393
pub async fn accept (
395
394
& self ,
396
395
alpn : impl AsRef < [ u8 ] > ,
@@ -408,10 +407,16 @@ impl Router {
408
407
reply_rx. await . map_err ( |_| RouterError :: Closed { } )
409
408
}
410
409
411
- /// Stops accepting a protocol.
410
+ /// Stops accepting connections with this `alpn`.
411
+ ///
412
+ /// After this function returns, new connections with `alpn` will no longer be accepted.
413
+ ///
414
+ /// If a protocol handler was registered for `alpn`, the handler will be
415
+ /// shutdown. Existing connections will not be aborted by the router, but some protocol
416
+ /// handlers may abort existing connnections in their [`Router::shutdown`] implementation.
417
+ /// Consult the documentation of the protocol handler to see if that is the case.
412
418
///
413
- /// Note that this has only an effect on new connections. Existing connections that were
414
- /// accepted with `alpn` won't be closed when calling [`Router::stop_accepting`].
419
+ /// Returns an error if the router has been shutdown or no protocol is registered for `alpn`.
415
420
pub async fn stop_accepting ( & self , alpn : impl AsRef < [ u8 ] > ) -> Result < ( ) , StopAcceptingError > {
416
421
let ( reply, reply_rx) = oneshot:: channel ( ) ;
417
422
self . tx
@@ -424,7 +429,7 @@ impl Router {
424
429
reply_rx. await . map_err ( |_| StopAcceptingError :: Closed { } ) ?
425
430
}
426
431
427
- /// Shuts down the accept loop cleanly.
432
+ /// Shuts down the accept loop and endpoint cleanly.
428
433
///
429
434
/// When this function returns, all [`ProtocolHandler`]s will be shutdown and
430
435
/// `Endpoint::close` will have been called.
@@ -459,8 +464,7 @@ impl RouterBuilder {
459
464
}
460
465
}
461
466
462
- /// Configures the router to accept the [`ProtocolHandler`] when receiving a connection
463
- /// with this `alpn`.
467
+ /// Configures the router to accept incoming connections with this `alpn` via [`ProtocolHandler`].
464
468
pub fn accept ( self , alpn : impl AsRef < [ u8 ] > , handler : impl ProtocolHandler ) -> Self {
465
469
self . protocols
466
470
. insert ( alpn. as_ref ( ) . to_vec ( ) , Arc :: new ( handler) ) ;
0 commit comments