Expand description
Pure, deterministic format registration and policy-controlled route planning.
Routes are loopless and returned in nondecreasing cost order. Equal-cost ordering is deterministic for a given graph, independent of edge registration order. Search uses reverse shortest-path distances to avoid exploring target-unreachable paths.
This crate only describes formats and routes. It does not inspect files, execute adapters, validate codec support, or guarantee conversion fidelity. Conversion classifications and costs are supplied by the graph’s registrant.
§Plan a conversion
use convert_rs_core::{Conversion, ConversionKind, Format, Graph, MediaKind, Policy};
let mut graph = Graph::new();
graph.add_format(Format::new("note", "Note", MediaKind::Text)
.with_extensions(&["txt"]))?;
graph.add_format(Format::new("speech", "Speech", MediaKind::Audio))?;
graph.add_conversion(Conversion::new(
"note", "speech", "reader", "speak", ConversionKind::Bridge, 3,
))?;
let routes = graph.routes(".TXT", "speech", &Policy::default())?;
assert_eq!(routes[0].cost, 3);
assert_eq!(routes[0].steps[0].operation, "speak");
let strict = Policy { allow_bridges: false, ..Policy::default() };
assert!(graph.routes("note", "speech", &strict).is_err());Structs§
- Content
Kind - A type of content carried inside or represented by a file.
- Content
Profile - The content streams a specific file or format representation carries.
- Conversion
- A directed conversion edge supplied by an adapter.
- Format
- A registered format and its lookup metadata.
- Graph
- An in-memory registry of formats and directed conversion edges.
- Plan
- An ordered sequence of conversion steps and its declared total cost.
- Policy
- Gates and search budgets used by
Graph::routes. - Stream
- One observed or declared stream inside a container.
Enums§
- Conversion
Category - A registered conversion’s role relative to the content’s ordinary purpose.
- Conversion
Kind - An adapter-declared description of a conversion’s semantics.
- Media
Kind - A format’s media category. Categories do not restrict graph connectivity.
- Plan
Error - Errors returned while validating or searching the conversion graph.