cqlib_core/visualization/mod.rs
1// This code is part of Cqlib.
2//
3// (C) Copyright China Telecom Quantum Group 2026
4//
5// This code is licensed under the Apache License, Version 2.0. You may
6// obtain a copy of this license in the LICENSE.txt file in the root directory
7// of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
8//
9// Any modifications or derivative works of this code must retain this
10// copyright notice, and modified files need to carry a notice indicating
11// that they have been altered from the originals.
12
13//! Visualization module for circuits, quantum states, and measurement results.
14//!
15//! This module provides SVG-first rendering pipelines for:
16//! - [`circuit`]: circuit diagrams (Unicode text and figure backends)
17//! - [`state`]: Bloch vectors, state-city, and Pauli expectation plots
18//! - [`result`]: histograms and probability distributions
19//!
20//! # Module Structure
21//!
22//! - [`circuit`]: IR builder, text drawer, and figure drawer
23//! - [`state`]: quantum-state visualization
24//! - [`result`]: result/statistics visualization
25//! - [`error`]: shared visualization error types
26//!
27//! # Examples
28//!
29//! ```rust
30//! use cqlib_core::circuit::{Circuit, Qubit};
31//! use cqlib_core::visualization::{FigureDrawerOptions, circuit_to_figure};
32//!
33//! let mut circuit = Circuit::new(2);
34//! circuit.h(Qubit::new(0)).unwrap();
35//! circuit.cx(Qubit::new(0), Qubit::new(1)).unwrap();
36//!
37//! let svg = circuit_to_figure(&circuit, &FigureDrawerOptions::default()).unwrap();
38//! assert!(svg.contains("<svg"));
39//! ```
40
41pub mod circuit;
42pub mod error;
43pub mod result;
44pub mod state;
45pub(crate) mod svg;
46
47// Re-export circuit visualization APIs at `visualization::*` for ergonomic use.
48pub use circuit::*;
49pub use error::VisualizationError;
50pub use result::*;
51pub use state::*;
52
53#[cfg(test)]
54mod test_utils;
55
56#[cfg(test)]
57#[path = "error_test.rs"]
58mod error_test;