pub struct TraceCollector { /* private fields */ }Expand description
Collects trace entries during transpilation.
Thread-safe collector that can be passed through the pipeline stages.
§Examples
use decy_core::trace::{TraceCollector, TraceEntry, DecisionType, PipelineStage};
let mut collector = TraceCollector::new();
assert!(collector.is_empty());
collector.record(TraceEntry {
stage: PipelineStage::CodeGeneration,
source_location: None,
decision_type: DecisionType::TypeMapping,
chosen: "i32".to_string(),
alternatives: vec!["i64".to_string()],
confidence: 1.0,
reason: "C int maps to Rust i32".to_string(),
});
assert_eq!(collector.len(), 1);
let json = collector.to_json();
assert!(json.contains("i32"));Implementations§
Source§impl TraceCollector
impl TraceCollector
Sourcepub fn record(&mut self, entry: TraceEntry)
pub fn record(&mut self, entry: TraceEntry)
Record a trace entry.
Sourcepub fn entries(&self) -> &[TraceEntry]
pub fn entries(&self) -> &[TraceEntry]
Get all recorded entries.
Sourcepub fn entries_for_stage(&self, stage: &PipelineStage) -> Vec<&TraceEntry>
pub fn entries_for_stage(&self, stage: &PipelineStage) -> Vec<&TraceEntry>
Filter entries by pipeline stage.
Sourcepub fn summary(&self) -> TraceSummary
pub fn summary(&self) -> TraceSummary
Get summary statistics.
Trait Implementations§
Source§impl Clone for TraceCollector
impl Clone for TraceCollector
Source§fn clone(&self) -> TraceCollector
fn clone(&self) -> TraceCollector
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TraceCollector
impl Debug for TraceCollector
Source§impl Default for TraceCollector
impl Default for TraceCollector
Source§fn default() -> TraceCollector
fn default() -> TraceCollector
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for TraceCollector
impl RefUnwindSafe for TraceCollector
impl Send for TraceCollector
impl Sync for TraceCollector
impl Unpin for TraceCollector
impl UnsafeUnpin for TraceCollector
impl UnwindSafe for TraceCollector
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more