Skip to main content

RebuildReporter

Struct RebuildReporter 

Source
pub struct RebuildReporter { /* private fields */ }
Expand description

Stateful terminal reporter for rebuild loops.

Tracks whether the previous output was a rolling rebuild line so the next line can either repaint it (consecutive success) or commit it with a newline (error, banner). Cheap to construct; not Clone — instances are typically owned by a single rebuild worker.

When stderr is not a TTY (piped to a logger, captured by tools like concurrently, or running in CI), the rolling line is replaced with plain newline-terminated lines so wrappers can flush each rebuild promptly.

Implementations§

Source§

impl RebuildReporter

Source

pub fn new() -> Self

Create a fresh reporter. Detects whether stderr is a TTY once.

Source

pub fn success(&mut self, elapsed: Duration, triggers: &[PathBuf])

Print a successful rebuild line. In an interactive terminal, consecutive successes repaint a single line in place; otherwise each rebuild prints its own newline-terminated line so log wrappers (concurrently, CI capture, file redirects) flush it.

triggers are the changed paths that caused this rebuild; the line names the first file (and (+N more) when several changed) so the developer can see what fired. An empty slice prints no trigger.

Always writes to stderr so it lands on the same stream as the rest of the dev server’s diagnostic output (banners, field tables, errors).

Source

pub fn error(&mut self, msg: &str)

Print a rebuild error, committing the previous rolling line first so it isn’t overwritten.

Each error block is framed with surrounding blank lines so that consecutive rebuild errors (e.g. repeated saves of a still-broken file) read as separate blocks instead of one squished wall. The leading blank is printed only for the first error in a run; every error prints a trailing blank, so two adjacent errors are separated by exactly one blank line.

Source

pub fn warnings(&mut self, messages: &[String])

Print non-fatal rebuild advisories, each framed with surrounding blank lines so they read as distinct blocks (matching error). The leading blank is printed only when the previous output was not itself a framed block; every advisory prints a trailing blank.

No-op when messages is empty, so clean rebuilds keep their in-place rolling line. Each message is the caller’s pre-rendered diagnostic body (the CLI colorizes per line); the reporter adds the ⚠ build warning: marker.

Source

pub fn commit_pending(&mut self)

Commit any pending rolling rebuild line with a trailing newline, so subsequent unrelated output (banner, info message) doesn’t land on the same line. No-op when not in interactive mode (those lines are already newline-terminated).

Trait Implementations§

Source§

impl Default for RebuildReporter

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more