Skip to main content

bark_json/
notifications.rs

1
2use crate::movements::Movement;
3
4
5
6
7/// A notification of something happening in the wallet
8#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
9#[serde(tag = "type", rename_all = "kebab-case")]
10#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
11pub enum WalletNotification {
12	/// A new movement was created
13	MovementCreated {
14		movement: Movement,
15	},
16	/// An existing movement was updated
17	MovementUpdated {
18		movement: Movement,
19	},
20	/// Some notifications were lost because they are not handled fast enough
21	ChannelLagging,
22}
23
24impl From<bark::WalletNotification> for WalletNotification {
25	fn from(v: bark::WalletNotification) -> Self {
26		match v {
27			bark::WalletNotification::MovementCreated { movement } => {
28				WalletNotification::MovementCreated { movement: movement.into() }
29			},
30			bark::WalletNotification::MovementUpdated { movement } => {
31				WalletNotification::MovementUpdated { movement: movement.into() }
32			},
33			bark::WalletNotification::ChannelLagging => WalletNotification::ChannelLagging,
34		}
35	}
36}