fn broadcast(msg: &str, sessions: &[InteractiveSession]) {
    let mut sessions_broadcasted: usize = 0;

    let broadcast_msg = format!(
        "\nBroadcast message from Zincati at {}:\n{}\n",
        chrono::Utc::now().format("%a %Y-%m-%d %H:%M:%S %Z"),
        msg
    );

    for session in sessions.iter() {
        // Write message to tty device.
        log::trace!(
            "Attempting to broadcast a message to user {} at {}",
            &session.user,
            &session.tty_dev
        );
        if let Err(e) = fs::write(&session.tty_dev, &broadcast_msg) {
            log::error!("failed to write to {}: {}", &session.tty_dev, e);
            continue;
        };

        sessions_broadcasted = sessions_broadcasted.saturating_add(1);
    }

    if sessions.len() != sessions_broadcasted {
        log::warn!(
            "{} interactive sessions found, but only broadcasted to {}",
            sessions.len(),
            sessions_broadcasted
        );
    }
}
/// Attempt to broadcast msg to sessions.
Attempt to broadcast msg to sessions.
Attempt to broadcast msg to sessions .
fn broadcast(msg: &str, sessions: &[InteractiveSession]) {
    let mut sessions_broadcasted: usize = 0;
    let broadcast_msg = format!(
        "\nBroadcast message from Zincati at {}:\n{}\n",
        chrono::Utc::now().format("%a %Y-%m-%d %H:%M:%S %Z"),
        msg
    );
    for session in sessions.iter() {
        // Write message to tty device.
        log::trace!(
            "Attempting to broadcast a message to user {} at {}",
            &session.user,
            &session.tty_dev
        );
        if let Err(e) = fs::write(&session.tty_dev, &broadcast_msg) {
            log::error!("failed to write to {}: {}", &session.tty_dev, e);
            continue;
        };
        sessions_broadcasted = sessions_broadcasted.saturating_add(1);
    }
    if sessions.len() != sessions_broadcasted {
        log::warn!(
            "{} interactive sessions found, but only broadcasted to {}",
            sessions.len(),
            sessions_broadcasted
        );
    }
}
fn broadcast ( msg : & str , sessions : & [ InteractiveSession ] ) { let mut sessions_broadcasted : usize = 0 ; let broadcast_msg = format ! ( " \n \n \n " chrono Utc now ( ) format ( " " ) msg ) ; for session in sessions . iter ( ) { // Write message to tty device. log :: trace ! ( " " session user session tty_dev ) ; if let Err ( e ) = fs :: write ( & session . tty_dev , & broadcast_msg ) { log :: error ! ( " " session tty_dev e ) ; continue ; } ; sessions_broadcasted = sessions_broadcasted . saturating_add ( 1 ) ; } if sessions . len ( ) != sessions_broadcasted { log :: warn ! ( " " sessions len ( ) sessions_broadcasted ) ; } }
Attempt to broadcast msg to sessions.
Attempt to broadcast msg to sessions .
msg
&str
sessions
&[InteractiveSession]