pub struct MetricsManager { /* private fields */ }metrics or otel-metrics only.Expand description
Metrics manager handling Prometheus and/or OTel exposition.
Implementations§
Source§impl MetricsManager
impl MetricsManager
Sourcepub fn with_config(config: MetricsConfig) -> Self
pub fn with_config(config: MetricsConfig) -> Self
Create a metrics manager with custom configuration.
Installs the appropriate recorder(s) based on enabled features:
metricsonly: Prometheus recorderotel-metricsonly: OTel recorder (OTLP push)- Both: Fanout recorder (Prometheus scrape + OTel OTLP push)
Sourcepub fn counter(&self, name: &str, description: &str) -> Counter
pub fn counter(&self, name: &str, description: &str) -> Counter
Create a counter metric.
Automatically registers a MetricDescriptor in the manifest registry
with empty labels and group = "custom".
Sourcepub fn counter_with_labels(
&self,
name: &str,
description: &str,
labels: &[&str],
group: &str,
) -> Counter
pub fn counter_with_labels( &self, name: &str, description: &str, labels: &[&str], group: &str, ) -> Counter
Create a counter with label keys and group metadata for the manifest.
The labels parameter declares label key names for the manifest.
The returned Counter is label-free – apply label values at recording
time via metrics::counter!(key, "label" => value).
Sourcepub fn gauge(&self, name: &str, description: &str) -> Gauge
pub fn gauge(&self, name: &str, description: &str) -> Gauge
Create a gauge metric.
Automatically registers a MetricDescriptor in the manifest registry
with empty labels and group = "custom".
Sourcepub fn gauge_with_labels(
&self,
name: &str,
description: &str,
labels: &[&str],
group: &str,
) -> Gauge
pub fn gauge_with_labels( &self, name: &str, description: &str, labels: &[&str], group: &str, ) -> Gauge
Create a gauge with label keys and group metadata for the manifest.
Sourcepub fn histogram(&self, name: &str, description: &str) -> Histogram
pub fn histogram(&self, name: &str, description: &str) -> Histogram
Create a histogram metric with default buckets.
Automatically registers a MetricDescriptor in the manifest registry
with empty labels and group = "custom".
Sourcepub fn histogram_with_labels(
&self,
name: &str,
description: &str,
labels: &[&str],
group: &str,
buckets: Option<&[f64]>,
) -> Histogram
pub fn histogram_with_labels( &self, name: &str, description: &str, labels: &[&str], group: &str, buckets: Option<&[f64]>, ) -> Histogram
Create a histogram with label keys, group, and optional buckets for the manifest.
Sourcepub fn histogram_with_buckets(
&self,
name: &str,
description: &str,
buckets: &[f64],
) -> Histogram
pub fn histogram_with_buckets( &self, name: &str, description: &str, buckets: &[f64], ) -> Histogram
Create a histogram metric with custom buckets.
Note: The buckets parameter is captured in the manifest registry
but currently ignored by the metrics crate at runtime (buckets are set
globally at recorder installation time).
Sourcepub fn render(&self) -> String
Available on crate feature metrics only.
pub fn render(&self) -> String
metrics only.Get the Prometheus metrics output.
Returns the rendered Prometheus text format. Only available when
the metrics feature is enabled.
Sourcepub fn render_handle(&self) -> Option<RenderHandle>
Available on crate feature metrics only.
pub fn render_handle(&self) -> Option<RenderHandle>
metrics only.Get a cloneable render handle for use in route handlers.
Returns a closure that renders the current Prometheus metrics text.
The closure is Send + Sync + Clone, making it safe to move into
axum route handlers or share across tasks via Arc.
Returns None if no Prometheus recorder is installed.
§Example
let mut mgr = MetricsManager::new("myapp");
let render = mgr.render_handle().expect("recorder installed");
// Use in axum route
let route = axum::Router::new().route("/metrics", axum::routing::get(move || {
let r = render.clone();
async move { r() }
}));
mgr.start_server_with_routes("0.0.0.0:9090", route).await?;Sourcepub fn set_readiness_check(
&mut self,
f: impl Fn() -> bool + Send + Sync + 'static,
)
pub fn set_readiness_check( &mut self, f: impl Fn() -> bool + Send + Sync + 'static, )
Set a readiness check callback.
When set, /readyz and /health/ready call this function and return
503 Service Unavailable if it returns false. Without a callback,
these endpoints always return 200.
Sourcepub fn mark_started(&self)
pub fn mark_started(&self)
Mark the service as started (startup probe passes).
Call this once init is complete. K8s startupProbe hits /startupz
which returns 503 until this is called, then 200 thereafter.
Separate from readiness – startup has a longer timeout for slow starters.
Sourcepub fn set_scaling_pressure(&mut self, sp: Arc<ScalingPressure>)
Available on crate features metrics and scaling only.
pub fn set_scaling_pressure(&mut self, sp: Arc<ScalingPressure>)
metrics and scaling only.Attach a ScalingPressure instance.
When set and using start_server_with_routes, a /scaling/pressure
endpoint is automatically added that returns the current pressure value.
Sourcepub fn set_memory_guard(&mut self, mg: Arc<MemoryGuard>)
Available on crate features memory and metrics only.
pub fn set_memory_guard(&mut self, mg: Arc<MemoryGuard>)
memory and metrics only.Attach a MemoryGuard instance.
When set and using start_server_with_routes, a /memory/pressure
endpoint is automatically added that returns the current memory status.
Sourcepub async fn start_server(&mut self, addr: &str) -> Result<(), MetricsError>
Available on crate feature metrics only.
pub async fn start_server(&mut self, addr: &str) -> Result<(), MetricsError>
metrics only.Start the metrics HTTP server.
Serves /metrics (Prometheus), /healthz, /health/live,
/readyz, /health/ready endpoints.
Only available when the metrics feature is enabled (for scraping).
§Errors
Returns an error if the server fails to start.
Sourcepub async fn start_server_with_routes(
&mut self,
addr: &str,
extra_routes: Router,
) -> Result<(), MetricsError>
Available on crate features http-server and metrics only.
pub async fn start_server_with_routes( &mut self, addr: &str, extra_routes: Router, ) -> Result<(), MetricsError>
http-server and metrics only.Start the metrics HTTP server with additional custom routes.
Serves the same built-in endpoints as start_server:
/metrics, /healthz, /health/live, /readyz, /health/ready.
Additionally:
- If
set_scaling_pressurewas called, adds/scaling/pressurereturning the current pressure value. - If
set_memory_guardwas called, adds/memory/pressurereturning memory status JSON. - Any routes in
extra_routesare merged (service-specific endpoints).
Requires both metrics and http-server features.
§Errors
Returns an error if the server fails to start.
Sourcepub async fn stop_server(&mut self) -> Result<(), MetricsError>
pub async fn stop_server(&mut self) -> Result<(), MetricsError>
Sourcepub fn shutdown_otel(&mut self)
Available on crate feature otel-metrics only.
pub fn shutdown_otel(&mut self)
otel-metrics only.Gracefully shut down the OTel provider (flushes pending exports).
Call this before application exit to ensure all metrics are exported.
Sourcepub fn set_build_info(&self, version: &str, commit: &str)
pub fn set_build_info(&self, version: &str, commit: &str)
Set application version and git commit for the manifest.
Uses interior mutability (writes through the registry’s Arc<RwLock>),
so only &self is needed. Called automatically by
dfe_groups::AppMetrics::new() if the metrics-dfe feature is enabled.
Sourcepub fn set_use_cases(&self, metric_name: &str, use_cases: &[&str])
pub fn set_use_cases(&self, metric_name: &str, use_cases: &[&str])
Set operational use cases for a metric (by full prefixed name).
No-op if the metric is not found in the registry.
Sourcepub fn set_dashboard_hint(&self, metric_name: &str, hint: &str)
pub fn set_dashboard_hint(&self, metric_name: &str, hint: &str)
Set the suggested Grafana panel type for a metric (by full prefixed name).
No-op if the metric is not found in the registry.
Sourcepub fn registry(&self) -> MetricRegistry
pub fn registry(&self) -> MetricRegistry
Get a cloneable handle to the metric registry.
Use this to pass into route handlers. The handle is Clone + Send + Sync.
Call before starting the server, consistent with the render_handle() pattern.
Sourcepub fn namespace(&self) -> &str
pub fn namespace(&self) -> &str
Get the namespace prefix (e.g. dfe_loader).
Used by dfe_groups metric structs to build labelled metric keys.
Auto Trait Implementations§
impl !RefUnwindSafe for MetricsManager
impl !UnwindSafe for MetricsManager
impl Freeze for MetricsManager
impl Send for MetricsManager
impl Sync for MetricsManager
impl Unpin for MetricsManager
impl UnsafeUnpin for MetricsManager
Blanket Implementations§
Source§impl<T> AnyExt for T
impl<T> AnyExt for T
Source§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
T behind referenceSource§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
T behind mutable referenceSource§fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
T behind Rc pointerSource§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
T behind Arc pointerSource§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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
fn coerce_rc_to(self: Rc<X>) -> Rc<T>
fn coerce_box_to(self: Box<X>) -> Box<T>
fn coerce_ref_to(&self) -> &T
fn coerce_mut_to(&mut self) -> &mut T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read moreSource§fn fg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
Source§fn bg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
Source§fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
Source§fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
Source§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);