asterust-junos 0.5.12

Typed Juniper JunOS config views (interfaces, protocols, routing instances and options, policy options, firewall filters, class of service, system, services) extracted from an asterust config tree.
Documentation
//! `keepalives`
//! `interfaces { <name> { keepalives interval <s> down-count <n> up-count <n>; } }`.
//!
//! # See also
//!
//! - [keepalives](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/keepalives-edit-interfaces.html)
//! - [no-keepalives](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/no-keepalives-edit-interfaces.html)

use crate::{statement_words, value_after};
use asterust::config::ConfigLine;

/// The `keepalives` settings of an interface; `no-keepalives` is a separate flag.
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct Keepalives {
    /// Seconds.
    pub interval: Option<String>,
    pub down_count: Option<String>,
    pub up_count: Option<String>,
}

pub(super) fn parse_keepalives(interface: &ConfigLine) -> Option<Keepalives> {
    let words = statement_words(interface, "keepalives")?;
    Some(Keepalives {
        interval: value_after(&words, "interval"),
        down_count: value_after(&words, "down-count"),
        up_count: value_after(&words, "up-count"),
    })
}