pub struct RecordingProgressSink { /* private fields */ }Expand description
Recording progress sink - captures events for testing.
This implementation records all progress events to an internal vector, allowing tests to verify that progress reporting is working correctly.
§Thread Safety
The internal event vector is protected by a Mutex, making this safe
to use with parallel analysis. However, the order of events may not
be deterministic when multiple threads are reporting simultaneously.
§Example
use debtmap::progress::implementations::{RecordingProgressSink, ProgressEvent};
use debtmap::progress::traits::ProgressSink;
let recorder = RecordingProgressSink::new();
recorder.start_stage("Test");
recorder.report("Test", 0, 5);
recorder.complete_stage("Test");
assert_eq!(recorder.stages(), vec!["Test"]);
assert!(recorder.events().iter().any(|e| matches!(e, ProgressEvent::Report { .. })));Implementations§
Source§impl RecordingProgressSink
impl RecordingProgressSink
Sourcepub fn events(&self) -> Vec<ProgressEvent>
pub fn events(&self) -> Vec<ProgressEvent>
Get all recorded events.
Returns a clone of the internal event vector.
Sourcepub fn stages(&self) -> Vec<String>
pub fn stages(&self) -> Vec<String>
Get all stage names that were started.
This is a convenience method for testing that extracts just the
stage names from StartStage events.
§Example
use debtmap::progress::implementations::RecordingProgressSink;
use debtmap::progress::traits::ProgressSink;
let recorder = RecordingProgressSink::new();
recorder.start_stage("Stage 1");
recorder.start_stage("Stage 2");
assert_eq!(recorder.stages(), vec!["Stage 1", "Stage 2"]);Sourcepub fn completed_stages(&self) -> Vec<String>
pub fn completed_stages(&self) -> Vec<String>
Get all completed stage names.
This is a convenience method for testing that extracts just the
stage names from CompleteStage events.
Sourcepub fn warnings(&self) -> Vec<String>
pub fn warnings(&self) -> Vec<String>
Get all warnings.
This is a convenience method for testing that extracts just the warning messages.
Sourcepub fn event_count(&self) -> usize
pub fn event_count(&self) -> usize
Get the number of recorded events.
Trait Implementations§
Source§impl Clone for RecordingProgressSink
impl Clone for RecordingProgressSink
Source§fn clone(&self) -> RecordingProgressSink
fn clone(&self) -> RecordingProgressSink
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RecordingProgressSink
impl Debug for RecordingProgressSink
Source§impl Default for RecordingProgressSink
impl Default for RecordingProgressSink
Source§fn default() -> RecordingProgressSink
fn default() -> RecordingProgressSink
Source§impl ProgressSink for RecordingProgressSink
impl ProgressSink for RecordingProgressSink
Auto Trait Implementations§
impl Freeze for RecordingProgressSink
impl RefUnwindSafe for RecordingProgressSink
impl Send for RecordingProgressSink
impl Sync for RecordingProgressSink
impl Unpin for RecordingProgressSink
impl UnsafeUnpin for RecordingProgressSink
impl UnwindSafe for RecordingProgressSink
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> EnsureExt<T> for T
impl<T> EnsureExt<T> for T
Source§fn ensure<P, E>(self, predicate: P, error: E) -> Validation<T, NonEmptyVec<E>>where
P: Predicate<T>,
fn ensure<P, E>(self, predicate: P, error: E) -> Validation<T, NonEmptyVec<E>>where
P: Predicate<T>,
Source§fn ensure_with<P, E, F>(
self,
predicate: P,
error_fn: F,
) -> Validation<T, NonEmptyVec<E>>
fn ensure_with<P, E, F>( self, predicate: P, error_fn: F, ) -> Validation<T, NonEmptyVec<E>>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more