Crate ovsdb

source ·
Expand description

A Rust implementation of the OVSDB schema and wire format.

ovsdb provides a Rust interface to an OVSDB server. It utilizes serde for protocol processing and tokio for asynchronous io. Its features include:

  • automated generation of Rust models via ovsdb-build
  • strongly typed interfaces to OVSDB data structures
  • automatic conversion to/from OVSDB protocol types

§Overview

Interacting with a database server is a 3-step process.

  1. Load a copy of the Schema for the database
  2. Build rust modules represent the Table’s in the schema
  3. Connect to the database via a Client and execute methods

Steps 1 and 2 above are handled by ovsdb-build.

§Requirements

To use the models generated by ovsdb-build, it is also necessary to install serde with the derive feature flag enabled.

$ cargo add serde --features derive

As ovsdb also utilizes tokio for asynchronous io and process management, an async runtime is required. See the tokio documentation for more details.

§Example

use std::path::Path;

use ovsdb::{Client, protocol::method::EchoResult};

#[tokio::main]
async fn main() -> Result<(), std::io::Error> {
    let client = Client::connect_unix(Path::new("/var/run/openvswitch/db.sock"))
        .await
        .unwrap();

    let result: EchoResult = client.echo(vec!["Hello", "OVSDB"]).await.unwrap();
    assert_eq!(*result, vec!["Hello".to_string(), "OVSDB".to_string()]);

    client.stop().await.unwrap();

    Ok(())
}

Re-exports§

Modules§

  • TCP/Unix socket based OVSDB client.
  • OVSDB wire protocol implementation
  • OVSDB Schema processing.

Macros§

Enums§

  • This type represents all errors that can occur within OVSDB.

Traits§

  • An entity that can be retrieved from OVSDB.

Type Aliases§