ovsdb-schema
A Rust implementation of the OVSDB protocol serialization and deserialization types.
Overview
This crate provides the core primitives and traits needed to work with the Open vSwitch Database Management Protocol (OVSDB) as defined in RFC7047. It includes:
- Type definitions for OVSDB data structures
- Serialization/deserialization between Rust types and OVSDB JSON format
- Traits to make your own types compatible with OVSDB
This crate is designed to be used alongside ovsdb-derive for a complete OVSDB client implementation.
Features
OvsdbAtomandOvsdbValuetypes representing OVSDB's basic data typesOvsdbSerializabletrait for converting between Rust types and OVSDB values- Implementations for common Rust types like
String,i64,bool, etc. - Support for collections like
Vec<T>andHashMap<K, V> - Helper functions for UUID handling
- Full support for OVSDB's type system: atoms, sets, and maps
Usage
Basic Usage
use ;
use HashMap;
use Uuid;
// Use the trait directly
let my_string = "hello".to_string;
let ovsdb_value = my_string.to_ovsdb;
let json_value = my_string.to_ovsdb_json.unwrap;
// Extract UUIDs from JSON values
let uuid_str = "550e8400-e29b-41d4-a716-446655440000";
let uuid = parse_str.unwrap;
let json_value = json!;
let extracted_uuid = extract_uuid.unwrap;
assert_eq!;
With ovsdb-derive
This crate is designed to work with the companion ovsdb-derive crate:
use ovsdb_object;
use HashMap;
// The macro adds _uuid and _version fields and implements
// OvsdbSerializable automatically
Type Conversion
| Rust Type | OVSDB Type |
|---|---|
String |
string |
i64 |
integer |
f64 |
real |
bool |
boolean |
Uuid |
uuid |
Vec<T> |
set |
HashMap<K, V> |
map |
Option<T> |
value or empty set |
Custom Types
Implement OvsdbSerializable for your custom types:
use ;
;
License
This project is licensed under the Apache License, Version 2.0.