#tokio #router #api #api-bindings #async #mikrotik #networking


Asynchronous Rust library for interfacing with MikroTik routers

3 releases (breaking)

0.3.0 Apr 24, 2024
0.2.0 Apr 4, 2024
0.1.0 Mar 28, 2024

#257 in Asynchronous

Download history 175/week @ 2024-03-26 188/week @ 2024-04-02 6/week @ 2024-04-09 111/week @ 2024-04-23

120 downloads per month

MIT license

762 lines

mikrotik-rs 📟

docs.rs Crates.io Crates.io License Libraries.io dependency status for latest release Crates.io Total Downloads GitHub Repo stars

This Rust library provides an asynchronous interface to interact with the Mikrotik API.

Features 🌟

  • No Unsafe Code 🛑: Built entirely in safe Rust, ensuring that your application is secure and free from memory-related vulnerabilities.
  • Concurrent Commands 🚦: Supports running multiple Mikrotik commands concurrently, with each command and its response efficiently managed via dedicated channels.
  • Asynchronous 🕒: Built on top of the Tokio runtime, this library offers non-blocking I/O operations.
  • Error Handling ⚠️: Designed with error handling in mind, ensuring that network or parsing errors are gracefully handled and reported back to the caller.

Getting Started 🚀

To use this library in your project, run the following command in your project's directory:

cargo add mikrotik-rs

Alternatively, you can add the library to your Cargo.toml file manually:

mikrotik-rs = "0.2.0"
tokio = { version = "1", features = ["full"] }

Ensure you have Tokio set up in your project as the library relies on the Tokio runtime.

Basic Usage 📖

use mikrotik_rs::{command::CommandBuilder, device::MikrotikDevice};
use tokio;

async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Initialize the MikrotikClient 🤖 with the router's address and access credentials
    let device = MikrotikDevice::connect("", "admin", Some("admin")).await?;

    // Execute a command 📝
    let get_system_res = CommandBuilder::new()
        // Send the update response every 1 second
        .attribute("interval", Some("1"))
    let response_channel = device.send_command(get_system_res).await;

    // Listen for the command's response 🔊
    while let Some(res) = response_channel.recv().await {
        println!(">> Get System Res Response {:?}", res);


Documentation 📚

For more detailed information on the library's API, please refer to the documentation.

Contributing 🤝

Contributions are welcome! Whether it's submitting a bug report 🐛, a feature request 💡, or a pull request 🔄, all contributions help improve this library. Before contributing, please read through the CONTRIBUTING.md file (if available) for guidelines.

License 📝

This project is licensed under the MIT License - see the LICENSE file for details.

Disclaimer 🚫

This library is not officially associated with Mikrotik. It is developed as an open-source project to facilitate Rust-based applications interacting with Mikrotik devices.


~118K SLoC