Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
graphviz-anywhere (Rust crate)
Rust crate published as graphviz-anywhere on crates.io.
Status
This crate currently builds against the legacy C-ABI wrapper
(capi/graphviz_api.{h,c}). A follow-up PR will switch the FFI surface
to the CGraphviz C++ class via the cxx crate so all platforms share
one Graphviz implementation.
Usage (native)
use ;
let ctx = new?;
let svg = ctx.render_to_string?;
println!;
Ship native binaries via one of:
- Environment:
GRAPHVIZ_ANYWHERE_DIR=/path/with/lib+include - Prebuilt: drop
libgraphviz_api.aunderpackages/rust/prebuilt/<os>/ - Repo build:
./scripts/build-<os>.shpopulatesoutput/<os>*/lib/
Usage (wasm32)
When compiled for wasm32-unknown-unknown the crate does not link the
native C library. Instead, GraphvizContext::render delegates to a
JavaScript function the host environment must install on globalThis:
// Contract (TypeScript):
declare global {
function __graphviz_anywhere_render(
dot: string,
engine: string, // "dot" | "neato" | "fdp" | "sfdp" | "circo" |
// "twopi" | "osage" | "patchwork"
format: string, // "svg" | "png" | "pdf" | "ps" | "json" |
// "dot" | "xdot" | "plain"
): string;
}
The function must return the rendered output as a string (for svg, the
SVG source; for binary formats the consumer is expected to interpret the
returned string as raw bytes). On failure, throw a JavaScript Error;
the thrown error is reported to Rust as
GraphvizError::RenderFailed.
Example wire-up with @kookyleo/graphviz-anywhere-web
import from "@kookyleo/graphviz-anywhere-web";
const graphviz = await ;
globalThis
graphviz.;
// Now any wasm-bindgen consumer that depends on `graphviz-anywhere`
// (e.g. `plantuml-little-web`) can call .render(...) normally.
Context lifetime on wasm32
GraphvizContext::new() on wasm32 is a zero-cost no-op that returns a
marker value; the real Graphviz context is owned by the JavaScript side.
Dropping a GraphvizContext is likewise a no-op on wasm32.