fn run_async<A, H>(
        config: Config<Self, A>,
        mut handler: H,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'static>>
    where
        A: Acceptor<Self::Transport>,
        H: Handler,
    {
        Box::pin(async move {
            if config.should_register_signals() {
                #[cfg(unix)]
                Self::spawn(Self::handle_signals(config.stopper()));

                #[cfg(not(unix))]
                log::error!("signals handling not supported on windows yet");
            }

            let mut listener = Self::build_listener(&config);
            let mut info = Self::info(&listener);
            info.server_description_mut().push_str(Self::DESCRIPTION);
            handler.init(&mut info).await;

            let handler = Arc::new(handler);
            let stopper = config.stopper.clone();
            while let Some(stream) = stopper.stop_future(Self::accept(&mut listener)).await {
                match stream {
                    Ok(stream) => {
                        Self::spawn(config.clone().handle_stream(stream, handler.clone()))
                    }
                    Err(e) => log::error!("tcp error: {}", e),
                }
            }

            config.graceful_shutdown().await;
            Self::clean_up(listener).await;
        })
    }
/// Run a trillium application from an async context. The default
/// implementation of this method contains the core logic of this
/// Trait.
Run a trillium application from an async context. The default
implementation of this method contains the core logic of this
Trait.
Run a trillium application from an async context . The default implementation of this method contains the core logic of this Trait .
fn run_async<A, H>(
        config: Config<Self, A>,
        mut handler: H,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'static>>
    where
        A: Acceptor<Self::Transport>,
        H: Handler,
    {
        Box::pin(async move {
            if config.should_register_signals() {
                #[cfg(unix)]
                Self::spawn(Self::handle_signals(config.stopper()));
                #[cfg(not(unix))]
                log::error!("signals handling not supported on windows yet");
            }
            let mut listener = Self::build_listener(&config);
            let mut info = Self::info(&listener);
            info.server_description_mut().push_str(Self::DESCRIPTION);
            handler.init(&mut info).await;
            let handler = Arc::new(handler);
            let stopper = config.stopper.clone();
            while let Some(stream) = stopper.stop_future(Self::accept(&mut listener)).await {
                match stream {
                    Ok(stream) => {
                        Self::spawn(config.clone().handle_stream(stream, handler.clone()))
                    }
                    Err(e) => log::error!("tcp error: {}", e),
                }
            }
            config.graceful_shutdown().await;
            Self::clean_up(listener).await;
        })
    }
fn run_async < A , H > ( config : Config < Self , A > , mut handler : H , ) -> Pin < Box < dyn Future < Output = ( ) > + Send + ' static > > where A : Acceptor < Self :: Transport > , H : Handler , { Box :: pin ( async move { if config . should_register_signals ( ) { # [ cfg ( unix ) ] Self :: spawn ( Self :: handle_signals ( config . stopper ( ) ) ) ; # [ cfg ( not ( unix ) ) ] log :: error ! ( " " ) ; } let mut listener = Self :: build_listener ( & config ) ; let mut info = Self :: info ( & listener ) ; info . server_description_mut ( ) . push_str ( Self :: DESCRIPTION ) ; handler . init ( & mut info ) . await ; let handler = Arc :: new ( handler ) ; let stopper = config . stopper . clone ( ) ; while let Some ( stream ) = stopper . stop_future ( Self :: accept ( & mut listener ) ) . await { match stream { Ok ( stream ) => { Self :: spawn ( config . clone ( ) . handle_stream ( stream , handler . clone ( ) ) ) } Err ( e ) => log :: error ! ( " " e ) , } } config . graceful_shutdown ( ) . await ; Self :: clean_up ( listener ) . await ; } ) }
Run a trillium application from an async context.
Run a trillium application from an async context .
config
Config<Self, A>
handler
H
config
Config<Self, A>
handler
H