oca 0.2.0

An experiment with no_std
Documentation
use core::time::Duration;

#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum KeepAlive {
    Seconds(u16),
    Milliseconds(u32),
}

impl KeepAlive {
    /// The interval this value represents.
    pub fn as_duration(&self) -> Duration {
        match self {
            KeepAlive::Seconds(secs) => Duration::from_secs(u64::from(*secs)),
            KeepAlive::Milliseconds(millis) => Duration::from_millis(u64::from(*millis)),
        }
    }
}

impl From<u16> for KeepAlive {
    fn from(value: u16) -> Self {
        KeepAlive::Seconds(value)
    }
}

impl From<u32> for KeepAlive {
    fn from(value: u32) -> Self {
        KeepAlive::Milliseconds(value)
    }
}