Basic structure of a notification using a struct and basic data types.
This commit is contained in:
parent
cbfc072966
commit
d497b9af67
44
src/main.rs
44
src/main.rs
@ -1,11 +1,23 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
enum ActionType {
|
||||
Normal,
|
||||
Default,
|
||||
}
|
||||
|
||||
struct NotifAction {
|
||||
key: String,
|
||||
label: String,
|
||||
}
|
||||
|
||||
struct Notif {
|
||||
app_name: String,
|
||||
replace_id: u32,
|
||||
ico: String, //It's string, right?
|
||||
summary: String,
|
||||
body: String,
|
||||
//Actions
|
||||
//Hints
|
||||
actions: Vec<(String, String)>,
|
||||
hints: HashMap<String, String>,
|
||||
expir_timeout: i32,
|
||||
}
|
||||
|
||||
@ -21,12 +33,34 @@ fn main() {
|
||||
let mut not = Notif {
|
||||
app_name: "snot".to_string(),
|
||||
replace_id: 0,
|
||||
ico: "alert".to_string(),
|
||||
ico: "alert.png".to_string(),
|
||||
summary: "This is a very long suuummmaaarrryyy! Don't you believe me????".to_string(),
|
||||
body: "short body(hehe)".to_string(),
|
||||
actions: vec![
|
||||
("reply".to_string(), "Reply".to_string()),
|
||||
("close".to_string(), "Close".to_string()),
|
||||
],
|
||||
hints: HashMap::new(), // Create an empty HashMap for hints
|
||||
expir_timeout: 0
|
||||
};
|
||||
|
||||
not.hints.insert("urgency".to_string(), "critical".to_string());
|
||||
truncate_summary(&mut not); //Limit the summary length
|
||||
|
||||
println!("{}",not.summary);
|
||||
}
|
||||
println!("AppName: {}\nReplaceId: {}\nIcon: {}\nSummary: {}\nBody: {}\nExpirationTimeout: {}",
|
||||
not.app_name,
|
||||
not.replace_id,
|
||||
not.ico,
|
||||
not.summary,
|
||||
not.body,
|
||||
not.expir_timeout
|
||||
);
|
||||
println!("Actions:");
|
||||
for (key, label) in ¬.actions {
|
||||
println!("\t{}: {}, ", key, label);
|
||||
}
|
||||
println!("Hints:");
|
||||
for (key, value) in not.hints.iter() {
|
||||
println!("\t{}: {}, ", key, value);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user