dev #2
@ -1,9 +1,10 @@
|
|||||||
// This module deals with converting the notification object into rson format, which can be used instead of json if preferred
|
// This module deals with converting the notification object into rson format, which can be used instead of json if preferred
|
||||||
use crate::notification::Notification;
|
use crate::notification::Notification;
|
||||||
use rson_rs::ser::to_string as rson_string;
|
use rson_rs::ser::to_string as rson_string;
|
||||||
|
use rson_rs::de::Error as RsonError;
|
||||||
|
|
||||||
impl Notification {
|
impl Notification {
|
||||||
pub fn rson(&self) -> Result<String, String> {
|
pub fn rson(&self) -> Result<String, RsonError> {
|
||||||
rson_string(self).map_err(|e| format!("Failed to serialize to RSON: {}", e))
|
rson_string(self).map_err(|e| RsonError::Message(format!("RSON serialization error: {}", e)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,11 @@ async fn main() -> Result<()> {
|
|||||||
println!("{}", ¬if.json()); // Print the json version
|
println!("{}", ¬if.json()); // Print the json version
|
||||||
}
|
}
|
||||||
"r" => {
|
"r" => {
|
||||||
println!("{}", ¬if.rson()); // Print the rson version
|
// Print the rson version
|
||||||
|
match notif.rson() {
|
||||||
|
Ok(rson_string) => println!("{}", rson_string),
|
||||||
|
Err(e) => eprintln!("Failed to convert to RSON: {}", e),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
"p" => {
|
"p" => {
|
||||||
println!("{}\n", ¬if.plain()); // Print the plain version
|
println!("{}\n", ¬if.plain()); // Print the plain version
|
||||||
|
Loading…
Reference in New Issue
Block a user