-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathevent.rs
More file actions
37 lines (34 loc) · 1.12 KB
/
Copy pathevent.rs
File metadata and controls
37 lines (34 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//! Messages originating from a PSU
use embedded_services::sync::Lockable;
use crate::{
capability::{ConsumerDisconnect, ConsumerPowerCapability, ProviderPowerCapability},
psu,
};
/// Data for an event broadcast from a PSU.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[non_exhaustive]
pub enum EventData {
/// Notify that a device has attached
Attached,
/// Notify that available power for consumption has changed
UpdatedConsumerCapability(Option<ConsumerPowerCapability>),
/// Request the given amount of power to provider
RequestedProviderCapability(Option<ProviderPowerCapability>),
/// Notify that a device cannot consume or provide power anymore
Disconnected(ConsumerDisconnect),
/// Notify that a device has detached
Detached,
}
/// Event broadcast from a PSU.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct Event<'a, D: Lockable>
where
D::Inner: psu::Psu,
{
/// Device that sent this request
pub psu: &'a D,
/// Event data
pub event: EventData,
}