deeplx 2.2.6

A Rust package for unlimited DeepL translation
Documentation
use std::sync::Arc;

use tokio::{signal, sync::watch::Sender};

pub async fn shutdown_signal(tx: Arc<Sender<()>>) {
    let ctrl_c = async {
        signal::ctrl_c()
            .await
            .expect("failed to install Ctrl+C handler");
    };

    #[cfg(unix)]
    let terminate = async {
        signal::unix::signal(signal::unix::SignalKind::terminate())
            .expect("failed to install signal handler")
            .recv()
            .await;
    };

    #[cfg(not(unix))]
    let terminate = std::future::pending::<()>();

    tokio::select! {
        _ = ctrl_c => {},
        _ = terminate => {},
        _ = tx.closed() => {},
    }
}