byteor_pipeline_lower/
lib.rs

1#![cfg_attr(not(feature = "std"), no_std)]
2#![deny(missing_docs)]
3#![deny(unreachable_pub, rust_2018_idioms)]
4#![forbid(unsafe_code)]
5
6//! Explicit lowering from plans into canonical pipeline specs.
7
8#[cfg(feature = "alloc")]
9extern crate alloc;
10
11mod common;
12mod diagnostics;
13mod error;
14mod lane_graph;
15mod options;
16mod single_ring;
17
18pub use diagnostics::{LowerDiagnosticCategoryV2, LowerDiagnosticV2, LowerReportV2};
19pub use error::{LowerError, Result};
20pub use lane_graph::lower_lane_graph_v2;
21pub use options::LowerOptionsV1;
22pub use single_ring::lower_single_ring_v2;
23
24#[cfg(feature = "alloc")]
25use byteor_pipeline_plan::{ExecutionTargetV1, PipelinePlanV2};
26
27#[cfg(feature = "alloc")]
28use crate::common::reject_v2;
29
30/// Lower a full-parity authoring document into the requested canonical target.
31#[cfg(feature = "alloc")]
32pub fn lower_v2(
33    plan: &PipelinePlanV2,
34    target: ExecutionTargetV1,
35    opts: &LowerOptionsV1,
36) -> Result<LowerReportV2> {
37    if plan.target != target {
38        return Err(reject_v2(
39            target,
40            LowerDiagnosticCategoryV2::TargetMismatch,
41            "explicit plan target does not match requested lowering target",
42        ));
43    }
44
45    match target {
46        ExecutionTargetV1::SingleRing => lower_single_ring_v2(plan, opts),
47        ExecutionTargetV1::LaneGraph => lower_lane_graph_v2(plan, opts),
48    }
49}
50
51#[cfg(all(test, feature = "alloc"))]
52mod tests;