Created input types.
This commit is contained in:
@ -1,19 +0,0 @@
|
||||
use core::cell::Cell;
|
||||
|
||||
/// Provides a view only reference to a [Cell].
|
||||
/// Useful alternative to `&Cell` when an API wants to control where a [Cell]s value can be set.
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct CellView<'a, T: Copy>(&'a Cell<T>);
|
||||
|
||||
impl<T: Copy> CellView<'_, T> {
|
||||
#[inline]
|
||||
pub fn get(self) -> T {
|
||||
self.0.get()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T: Copy> From<&'a Cell<T>> for CellView<'a, T> {
|
||||
fn from(value: &'a Cell<T>) -> Self {
|
||||
CellView(value)
|
||||
}
|
||||
}
|
@ -1,4 +1,7 @@
|
||||
#![feature(async_fn_in_trait)]
|
||||
|
||||
pub mod cell;
|
||||
mod transducer;
|
||||
mod transducer;
|
||||
|
||||
pub mod cell {
|
||||
pub use physical::cell::*;
|
||||
}
|
||||
|
@ -1,2 +1,30 @@
|
||||
use crate::cell::CellView;
|
||||
#[cfg(feature = "embassy-sync")]
|
||||
use embassy_sync::blocking_mutex::raw::RawMutex;
|
||||
#[cfg(feature = "embassy-sync")]
|
||||
use embassy_sync::pubsub::PubSubChannel;
|
||||
pub use physical::transducer::input::*;
|
||||
|
||||
#[cfg(feature = "embassy-sync")]
|
||||
pub struct ChannelInput<
|
||||
T: Copy,
|
||||
MutexT: RawMutex,
|
||||
const CAPACITY: usize,
|
||||
const NUM_SUBS: usize,
|
||||
const NUM_PUBS: usize,
|
||||
> {
|
||||
channel: PubSubChannel<MutexT, T, CAPACITY, NUM_SUBS, NUM_PUBS>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "embassy-sync")]
|
||||
pub struct StatefulChannelInput<
|
||||
'a,
|
||||
T: Copy,
|
||||
MutexT: RawMutex,
|
||||
const CAPACITY: usize,
|
||||
const NUM_SUBS: usize,
|
||||
const NUM_PUBS: usize,
|
||||
> {
|
||||
pub state_cell: CellView<'a, T>,
|
||||
channel: PubSubChannel<MutexT, T, CAPACITY, NUM_SUBS, NUM_PUBS>,
|
||||
}
|
||||
|
Reference in New Issue
Block a user