pub struct Control {
pub limits: Option<Power<Limit>>,
pub failsafes: Option<Power<i64>>,
pub trust: Option<Vec<TrustEntry>>,
pub notify: Option<Notify>,
}Expand description
Backend desired settings. A standalone control carries exactly one property and,
for limits and failsafes, exactly one direction.
On the wire both power properties nest as power.active.{consumption,production}.
The library flattens that to Power and rejects a direction at any other level.
use cls_eedi::wire::{Control, Limit, Message, Payload, Power, WireError};
let control = Control::limits(Power::consumption(Limit::active(4200).lasting(60)));
let json = r#"{"type":"de.keo-connectivity.clseedi.control","id":"limit-1",
"source":"operator","specversion":"1.0","data":{"protocol":"1.2.0",
"limits":{"power":{"active":{"consumption":{"value":4200,"active":true,"duration":60}}}}}}"#;
assert_eq!(Message::decode(json.as_bytes())?.payload, Payload::Control(control));
let misplaced = json.replace(r#"{"power":{"active":{"consumption""#, r#"{"consumption""#)
.replace("}}}}}}", "}}}}");
assert_eq!(
Message::decode(misplaced.as_bytes()),
Err(WireError::Field("limits direction outside power.active"))
);Fields§
§limits: Option<Power<Limit>>§failsafes: Option<Power<i64>>§trust: Option<Vec<TrustEntry>>§notify: Option<Notify>Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Control
impl<'de> Deserialize<'de> for Control
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Control
impl StructuralPartialEq for Control
Auto Trait Implementations§
impl Freeze for Control
impl RefUnwindSafe for Control
impl Send for Control
impl Sync for Control
impl Unpin for Control
impl UnsafeUnpin for Control
impl UnwindSafe for Control
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more