success_message
Success message composed from
Id and FieldList components.struct Component
pub struct ComponentRenders a success message with a checkmark icon, action text, optional entity ID, and optional key-value fields.
The checkmark uses the message.success.icon
style and the action text uses
success.
| Field | Type | Description |
|---|---|---|
action |
String | Action text after the checkmark, such as created task. |
fields |
FieldList | Fields shown after a blank line under the action line. |
has_fields |
bool | Whether any field was added, so the blank line and list are printed. |
id |
Option<String> | Entity ID shown after the action; None shows no ID. |
prefix_len |
usize | Highlighted prefix length of the ID. |
Implements Display.
Component::new
pub fn new(action: impl Into<String>) -> SelfCreate a success message with the given action text.
| Parameter | Type | Description |
|---|---|---|
action |
impl Into<String> | what was done, such as created task |
| returns | Self | The message with no ID or fields, and a 2-character ID prefix. |
Component::field
pub fn field(self, label: impl Into<String>, value: impl Into<String>) -> SelfAppend a label-value pair below the action line.
| Parameter | Type | Description |
|---|---|---|
label |
impl Into<String> | the field name |
value |
impl Into<String> | the field value |
| returns | Self | The message with the field added. |
Component::id
pub fn id(self, id: impl Into<String>) -> SelfSet the entity ID to display after the action text.
| Parameter | Type | Description |
|---|---|---|
id |
impl Into<String> | the full entity ID; at most 8 characters are shown |
| returns | Self | The message with the ID set. |
Component::prefix_len
pub fn prefix_len(self, len: usize) -> SelfSet the highlighted prefix length passed to the rendered Id.
| Parameter | Type | Description |
|---|---|---|
len |
usize | the number of highlighted characters |
| returns | Self | The message with the new prefix length. |