powerlink-rs 0.1.0

Platform-agnostic core logic for Ethernet POWERLINK Rust implementation.
Documentation
// In frame/error/manager.rs

use super::traits::{ErrorCounters, ErrorHandler};
use super::types::{DllError, NmtAction};

/// The central manager, generic over the counter set and the handler.
pub struct DllErrorManager<C, H>
where
    C: ErrorCounters,
    H: ErrorHandler,
{
    pub counters: C,
    pub handler: H,
}

impl<C, H> DllErrorManager<C, H>
where
    C: ErrorCounters,
    H: ErrorHandler,
{
    pub fn new(counters: C, handler: H) -> Self {
        Self { counters, handler }
    }

    pub fn handle_error(&mut self, error: DllError) -> NmtAction {
        self.counters.handle_error(error, &mut self.handler)
    }

    pub fn on_cycle_complete(&mut self) {
        self.counters.on_cycle_complete();
    }
}