Skip to main content

warning

Function warning 

Source
pub fn warning(msg: Message) -> String
Expand description

Creates a warning message with a yellow warning triangle prefix.

This function provides a standardized way to format warning messages throughout the application. Warnings indicate situations that require user attention but are not necessarily errors or failures.

§Visual Format

Warning messages are prefixed with a yellow warning triangle (⚠️) to indicate important information that users should be aware of. This provides a visual middle ground between informational and error messages.

§Warning Message Types

Warnings are appropriate for these scenarios:

  • Deprecation Notices: Features that will be removed in future versions
  • Configuration Issues: Non-critical configuration problems
  • Data Quality: Potential issues with user data or inputs
  • Performance Notices: Operations that might be slow or resource-intensive
  • Compatibility Warnings: Version or platform compatibility concerns

§Usage Context

This function is typically used for:

  • Non-critical configuration issues
  • Deprecated feature usage notifications
  • Data quality concerns or anomalies
  • Performance or resource usage warnings
  • Compatibility or version mismatch notices

§Arguments

  • msg - A Message enum variant containing the warning details

§Returns

Returns a formatted string with the warning prefix and message text.

§Examples

use kasl::libs::messages::{Message, warning};

// Format a configuration warning
let message = warning(Message::AutostartRequiresAdmin);
println!("{}", message); // "⚠️  Administrator privileges required for system-level autostart."

// Data quality warning
let data_warning = warning(Message::ShortIntervalsDetected(3, "45 minutes".to_string()));
println!("{}", data_warning); // "⚠️  Detected 3 short intervals totaling 45 minutes"

§Integration with Application Flow

Warnings often provide guidance for resolution:

use kasl::msg_warning;
use kasl::libs::messages::Message;

// Warning with follow-up guidance
let count = 3;
let duration = "45 minutes".to_string();
msg_warning!(Message::ShortIntervalsDetected(count, duration));