Skip to main content

DiagnosticSupport

Struct DiagnosticSupport 

Source
pub struct DiagnosticSupport<E: DiagnosticRecord, H: DiagnosticHookDispatch<E>> { /* private fields */ }
Expand description

Shared state for optional diagnostic logging plus optional telemetry hooks.

This is the reusable control-flow skeleton shared by diagnostic-enabled widgets and screens:

  • optional bounded log
  • optional hook collection
  • shared record() ordering: hooks first, then log

Implementations§

Source§

impl<E: DiagnosticRecord, H: DiagnosticHookDispatch<E>> DiagnosticSupport<E, H>

Source

pub fn new() -> Self

Create an empty diagnostic support bundle with no log and no hooks.

Source

pub fn with_log(self, log: DiagnosticLog<E>) -> Self

Enable logging with the provided diagnostic log.

Source

pub fn with_hooks(self, hooks: H) -> Self

Enable telemetry hooks with the provided hook set.

Source

pub fn set_log(&mut self, log: DiagnosticLog<E>)

Replace the diagnostic log.

Source

pub fn set_hooks(&mut self, hooks: H)

Replace the telemetry hooks.

Source

pub fn log(&self) -> Option<&DiagnosticLog<E>>

Borrow the diagnostic log, if enabled.

Source

pub fn log_mut(&mut self) -> Option<&mut DiagnosticLog<E>>

Mutably borrow the diagnostic log, if enabled.

Source

pub fn hooks(&self) -> Option<&H>

Borrow the telemetry hooks, if enabled.

Source

pub fn is_active(&self) -> bool

Returns true when either logging or hooks are enabled.

Source

pub fn record(&mut self, entry: E)

Dispatch an entry to hooks first, then record it to the log.

Trait Implementations§

Source§

impl<E: DiagnosticRecord, H: DiagnosticHookDispatch<E>> Debug for DiagnosticSupport<E, H>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<E: DiagnosticRecord, H: DiagnosticHookDispatch<E>> Default for DiagnosticSupport<E, H>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<E, H> Freeze for DiagnosticSupport<E, H>
where H: Freeze,

§

impl<E, H> RefUnwindSafe for DiagnosticSupport<E, H>

§

impl<E, H> Send for DiagnosticSupport<E, H>
where H: Send, E: Send,

§

impl<E, H> Sync for DiagnosticSupport<E, H>
where H: Sync, E: Sync,

§

impl<E, H> Unpin for DiagnosticSupport<E, H>
where H: Unpin, E: Unpin,

§

impl<E, H> UnsafeUnpin for DiagnosticSupport<E, H>
where H: UnsafeUnpin,

§

impl<E, H> UnwindSafe for DiagnosticSupport<E, H>
where H: UnwindSafe, E: UnwindSafe,

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, 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