pub fn wrap_msg(msg: Message) -> StringExpand description
Wraps a message with newlines for emphasis and visual separation.
This function provides enhanced visual formatting for messages that require special emphasis or clear separation from surrounding content. It adds newlines before and after the message text to create visual whitespace that draws attention to important information.
§Visual Format
Wrapped messages are formatted with newlines on both sides:
Your important message here
This creates clear visual separation from other content and emphasizes the importance of the message.
§Usage Context
Message wrapping is appropriate for:
- Critical Announcements: Important system notifications
- Section Headers: Major section dividers in output
- Final Results: Summary information at the end of operations
- Error Emphasis: Critical errors that require immediate attention
- Interactive Prompts: Important questions or confirmations
§Design Considerations
Wrapped messages should be used sparingly to maintain their emphasis effect. Overuse can clutter the interface and reduce the impact of truly important messages.
§Arguments
msg- AMessageenum variant to be wrapped with emphasis
§Returns
Returns a formatted string with newlines before and after the message text.
§Examples
use kasl::libs::messages::{Message, wrap_msg};
// Emphasize a critical message
let message = wrap_msg(Message::ConfirmDeleteAllTodayTasksFinal);
println!("{}", message);
// Output:
//
// This action cannot be undone. Continue?
//
// Wrap a summary message
let summary = wrap_msg(Message::AllMigrationsCompleted);
println!("{}", summary);
// Output:
//
// All migrations completed successfully
//§Integration with Other Formatting
Wrapped messages can be combined with prefix functions:
use kasl::libs::messages::{Message, success, wrap_msg};
// Create an emphasized success message using the prefix function directly
let emphasized_success = format!("\n{}\n", success(Message::OperationCompleted));
// Or use wrap_msg directly on the Message for consistent formatting
let wrapped_success = wrap_msg(Message::OperationCompleted);