adds command registration

This commit is contained in:
2025-11-30 08:50:35 -08:00
parent d53d78434c
commit ea56b9865e
5 changed files with 76 additions and 92 deletions

View File

@@ -5,17 +5,18 @@ use std::time::Instant;
pub trait PinDevice {
fn set_pin(&self, pin: u8, value: PinState, valid_until: Instant, priority: u8);
fn new_pinset_callback(self) -> impl Fn(ValidPriorityCommand<SetPin>)
fn new_pinset_callback<'a>(&self) -> impl Fn(ValidPriorityCommand<SetPin>) + 'a
where
Self: Sized,
Self: Sized + Clone + 'a,
{
let this = self.clone();
move |cmd| {
self.set_pin(
this.set_pin(
cmd.pin,
cmd.value.into(),
cmd.get_valid_until_instant(),
cmd.priority,
)
);
}
}
}