Expand description
§mikrotik-proto
Sans-IO protocol implementation for the MikroTik RouterOS API.
This crate provides a runtime-agnostic, no_std-compatible implementation
of the MikroTik RouterOS API wire protocol. It handles:
- Wire-format encoding/decoding — variable-length prefix codec for words and sentences
- Command building — typestate builder pattern with compile-time validation
- Response parsing — zero-copy sentence parsing into typed responses
- Connection state machine — multiplexed command/response correlation
- Login handshake — typestate-enforced authentication flow
This crate performs no I/O. It accepts byte slices as input and produces
byte buffers and events as output. A runtime adapter (e.g., mikrotik-tokio)
is responsible for actual network communication.
§Feature flags
| Feature | Default | Description |
|---|---|---|
std | no | Uses std::collections::HashMap in public types. When disabled (default), falls back to hashbrown::HashMap for no_std compatibility. |
§Architecture
┌─────────────────────────────────────────────────────┐
│ mikrotik-proto (this crate) │
│ │
│ codec (RawSentence) ──▶ response │
│ ▲ │
│ command ─────────────────┘ │
│ │
│ connection (state machine, multiplexing) │
│ handshake (typestate login flow) │
└─────────────────────────────────────────────────────┘
▲ receive(&[u8]) │ poll_transmit()
│ │ poll_event()
│ ▼
┌─────────────────────────────────────────────────────┐
│ Runtime adapter (e.g., mikrotik-tokio) │
│ Thin async glue: TcpStream ↔ Connection │
└─────────────────────────────────────────────────────┘Re-exports§
pub use command::Command;pub use command::CommandBuilder;pub use connection::Connection;pub use connection::Event;pub use connection::State;pub use connection::Transmit;pub use handshake::Authenticated;pub use handshake::Handshaking;pub use handshake::LoginProgress;pub use response::CommandResponse;pub use tag::Tag;
Modules§
- codec
- Wire-format codec for MikroTik API length-prefixed words and sentences. Wire-format codec for MikroTik API length-prefixed words and sentences.
- command
- Command builder with typestate pattern and compile-time validation. Command builder with typestate pattern and compile-time validation.
- connection
- Sans-IO connection state machine with multiplexed command/response correlation. Sans-IO connection state machine with multiplexed command/response correlation.
- error
- Error types for the protocol implementation. Error types for the MikroTik protocol implementation.
- handshake
- Typestate-enforced login handshake. Typestate-enforced login handshake.
- macros
- Compile-time command path validation and
command!macro. Compile-time command path validation andcommand!macro. - response
- Response types for parsed command responses. Response types for parsed command responses.
- tag
- Command tag — a unique identifier for correlating commands with responses. Command tag — a unique identifier for correlating commands with responses.
- word
- Word types: the fundamental unit of the MikroTik API protocol. Word types: the fundamental unit of the MikroTik API protocol.
Macros§
- command
- Macro that enforces
MikroTikcommand syntax at compile time.
Structs§
- HashMap
- A hash map implemented with quadratic probing and SIMD lookup.