lazybar_types/lib.rs
1use std::fmt::Display;
2
3use serde::{Deserialize, Serialize};
4
5/// A response to an event
6#[derive(
7 Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize,
8)]
9pub enum EventResponse {
10 /// The event executed normally
11 Ok(Option<String>),
12 /// An error occurred
13 Err(String),
14}
15
16impl Display for EventResponse {
17 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
18 match self {
19 Self::Ok(s) => write!(f, "{}", s.as_deref().unwrap_or("SUCCESS")),
20 Self::Err(e) => {
21 write!(f, "FAILURE: {e}")
22 }
23 }
24 }
25}