Versionless data models for MikroTik RouterOS API responses.
RouterOS API replies are string maps whose fields vary by RouterOS version, installed package, hardware platform, and local configuration. This crate provides typed row structs and reusable primitive parsers while keeping that variability explicit with optional fields.
| Module | Purpose |
|---|---|
api |
RouterOS API response rows grouped by menu namespace. |
primitives |
Reusable RouterOS scalar types such as IDs, byte sizes, durations, IP prefixes, and routing values. |
target |
Connection target and credential types shared with mikrotik-client. |
device |
Higher-level device snapshot models composed from API rows. |
topology |
Higher-level topology/domain models. |
Endpoint structs follow the RouterOS menu path in PascalCase. For example:
| RouterOS command | Rust type |
|---|---|
/interface/print |
api::interface::Interface |
/interface/ethernet/switch/port/print |
api::interface::EthernetSwitchPort |
/ip/settings/print |
api::ip::IpSettings |
/routing/stats/origin/print |
api::routing::RoutingStatsOrigin |
Rows can be deserialized directly from raw RouterOS API maps:
use mikrotik_types::Row;
use mikrotik_types::api::system::Identity;
let row = Row::from([("name".to_owned(), "lab-router".to_owned())]);
let identity: Identity = mikrotik_types::deserialize(&row)?;
assert_eq!(identity.name.as_deref(), Some("lab-router"));
# Ok::<(), serde_json::Error>(())With mikrotik-client, typed print commands deserialize into these structs:
# use mikrotik_client::commands;
# use mikrotik_client::client::AsyncClient;
# async fn example(client: &AsyncClient) -> mikrotik_client::error::Result<()> {
let resources = client
.print::<mikrotik_client::types::api::system::Resource>(
commands::PrintCommand::System(commands::System::Resource),
)
.await?;
println!("resource rows: {}", resources.len());
# Ok(())
# }mikrotik-types is no_std with alloc. The workspace test task builds the
crate for a no-std target as part of normal verification.
The crate is intentionally versionless: one type attempts to model the stable shape of an endpoint across RouterOS versions, with optional fields for values that are version-, platform-, package-, or configuration-dependent.
Fixture tests cover captured live rows, and mikrotik-qemu-runner exercises typed
deserialization against real CHR images across the cataloged RouterOS versions.