2 unstable releases
0.2.0 | Oct 11, 2023 |
---|---|
0.1.0 | Mar 10, 2023 |
#2236 in Parser implementations
28 downloads per month
Used in dot-viewer
39KB
917 lines
dot-graph
dot parser in Rust implemented with FFI to Graphviz cgraph library.
Prerequisites
dot-graph
parses a dot format file using C bindings to Graphviz (v7.0.6).
The system environment should be able to find and include the following header files.
#include <gvc.h>
#include <cgraph.h>
Option 1. Installing Graphviz from Package Manager
Coming from Linux,
$ sudo apt install graphviz-dev
And coming from vanilla Ubuntu, you may want to install these too.
$ sudo apt install build-essentials cmake
$ sudo apt install clang
Coming from Mac,
$ brew install graphviz
And coming from Apple Silicon Mac, and add an environment variable,
export CPATH=/opt/homebrew/include
Option 2. Building Graphviz from Source
Or, try building from the source code yourself following the guide.
Usage
use dot_graph::prelude::*;
fn main() -> Result<(), DotGraphError> {
/* parse from file */
let graph = parser::parse_from_file(/* path */)?;
let mut stdout = std::io::stdout();
graph.to_dot(&mut stdout)?;
/* parse from memory */
let graph = parser::parse_from_memory(/* dot file contents in memory */)?;
let mut stdout = std::io::stdout();
graph.to_dot(&mut stdout)?;
Ok(())
}
Dependencies
~2.7–9.5MB
~104K SLoC