ovsdb-build

Crates.ioovsdb-build
lib.rsovsdb-build
version0.0.6
sourcesrc
created_at2024-02-21 00:42:40.061426
updated_at2024-02-21 01:12:11.593974
descriptionOVSDB schema compiler
homepagehttps://git.dubzland.com/holodekk/ovsdb
repositoryhttps://git.dubzland.com/holodekk/ovsdb.git
max_upload_size
id1147403
size30,026
Josh Williams (t3hpr1m3)

documentation

https://docs.rs/ovsdb-build/0.0.6

README

ovsdb-build

Compiles an OVSDB schema into Rust models and proxies for typed database interaction in ovsdb.

Overview

In order to interact with an OVSDB instance in a type-safe manner, we need to create strongly-typed structs that map to the tables within OVSDB. ovsdb-build accepts an OVSDB schema and, for each table, generates 2 structs:

  • a native struct used by the client application, and
  • a proxy struct, utilized by serde to handle encoding/decoding messages

The conversions are primarily handled by newtype wrappers around existing Rust types, so should be extremely efficient.

Before you can build, however, you need a schema. For instance, let's assume you want to interact with the Open vSwitch database. The first thing you'll need to do is obtain a copy of the schema (usually stored with a .ovsschema extension). The schema file can be found in the repository, or obtained by connecting directly to an OVSDB instance. If you're running Open vSwitch, then a copy of OVSDB is already running on your machine (usually listening on a local socket). For example, on my local machine, I can connect and download a copy of the schema with the following command:

# ovsdb-client get-schema /var/run/openvswitch/db.sock > /tmp/vswitch.ovsschema

Note that connecting to the OVSDB socket requires root priveleges. Before proceeding, it is probably worth taking a look at the schema file itself, as the OVSDB schema introduces a few concepts not present in other database systems.

Installation

Simply add ovsdb-build as a dependency, either via cargo:

$ cargo add --build ovsdb-build

or directly to Cargo.toml:

[build-dependencies]
ovsdb-build = <ovsdb-version>

Example

Assuming the schema downloaded earlier is in /tmp/vswitch.ovsschema, in build.rs:

fn main() -> Result<(), Box<dyn std::error::Error>> {
    ovsdb_build::configure().compile("/tmp/vswitch.ovsschema", "vswitch")?;
    Ok(())
}

License

This project is licensed under the MIT license.

Author

Commit count: 0

cargo fmt