///|
/// Timestamp represents a monotonic point in time, in nanoseconds.
pub(all) enum Timestamp {
Timestamp(Int64)
} derive(Eq, Debug, Compare)
///|
/// Duration represents a span of time, in nanoseconds.
pub(all) enum Duration {
Duration(Int64)
} derive(Eq, Debug, Compare)
///|
/// NicHandle is an opaque network interface handle provided by the HAL backend.
pub(all) struct NicHandle {
id : Int
} derive(Eq, Debug)
///|
/// The maximum size of an EtherCAT frame payload (Ethernet MTU).
pub let max_frame_size : Int = 1518
///|
/// The EtherCAT EtherType constant (0x88A4).
pub let ethercat_ethertype : Int = 0x88A4
///|
/// Nic defines the minimal network interface contract.
/// All platform backends must implement this trait.
pub(open) trait Nic {
/// Open a network interface by name.
fn open_(String) -> Self raise EcError
/// Send a raw Ethernet frame. Returns bytes sent.
fn send(Self, Bytes) -> Int raise EcError
/// Receive a raw Ethernet frame.
/// Returns the received frame bytes.
fn recv(Self, timeout~ : Duration) -> Bytes raise EcError
/// Close the network interface and release resources.
fn close(Self) -> Unit
}
///|
/// Clock provides monotonic timing primitives.
pub(open) trait Clock {
/// Return the current monotonic timestamp in nanoseconds.
fn now(Self) -> Timestamp
/// Sleep for the specified duration.
fn sleep(Self, Duration) -> Unit
}
///|
/// FileAccess provides basic file I/O for configuration and diagnostics.
pub(open) trait FileAccess {
/// Read the entire contents of a file as Bytes.
fn read_file(Self, String) -> Bytes raise EcError
/// Write Bytes to a file, creating or overwriting it.
fn write_file(Self, String, Bytes) -> Unit raise EcError
}