A procedural macro crate for Rust to generate code for OVSDB table structs.
This crate provides two approaches for working with OVSDB tables:
#[ovsdb_object]
attribute macro: Automatically adds _uuid
and _version
fields to your struct#[derive(OVSDB)]
derive macro: requires manual fields but offers more controlYou can either use the attribute macro or the derive macro to generate code for your OVSDB table structs. For more details on how to use the library, check out the examples in the examples
directory.
use ovsdb_derive::ovsdb_object; use std::collections::HashMap; #[ovsdb_object] pub struct NbGlobal { pub name: Option<String>, pub nb_cfg: Option<i64>, pub external_ids: Option<HashMap<String, String>>, // No need to add _uuid and _version fields }
use ovsdb_derive::OVSDB; use std::collections::HashMap; use uuid::Uuid; #[derive(Debug, Clone, PartialEq, OVSDB)] pub struct NbGlobal { pub name: Option<String>, pub nb_cfg: Option<i64>, pub external_ids: Option<HashMap<String, String>>, // Required fields with the derive approach pub _uuid: Option<Uuid>, pub _version: Option<Uuid>, }
Both macros generate the following implementations:
new()
method that creates a new instance with default valuesto_map()
method that converts the struct to a HashMap for OVSDB serializationfrom_map()
method that creates a struct from a HashMap received from OVSDBDefault
trait implementationserde::Serialize
trait implementationserde::Deserialize
trait implementationThis project is licensed under the Apache License, Version 2.0.