pub struct SensorWorker { /* private fields */ }Expand description
Background worker that handles BLE operations.
The worker receives commands from the UI thread and performs Bluetooth operations asynchronously, sending events back to update the UI state.
Note: The Store is not held directly because rusqlite’s Connection is not Send+Sync. Instead, we store the path and open the store when needed.
Implementations§
Source§impl SensorWorker
impl SensorWorker
Sourcepub fn new(
command_rx: Receiver<Command>,
event_tx: Sender<SensorEvent>,
store_path: PathBuf,
) -> Self
pub fn new( command_rx: Receiver<Command>, event_tx: Sender<SensorEvent>, store_path: PathBuf, ) -> Self
Create a new sensor worker.
§Arguments
command_rx- Channel receiver for commands from the UIevent_tx- Channel sender for events to the UIstore_path- Path to persistent storage
The worker is created with a default poll interval of 60 seconds.
Sourcepub async fn run(self)
pub async fn run(self)
Run the worker’s main loop.
This method consumes the worker and runs until a Command::Shutdown
is received or the command channel is closed.
Auto Trait Implementations§
impl Freeze for SensorWorker
impl RefUnwindSafe for SensorWorker
impl Send for SensorWorker
impl Sync for SensorWorker
impl Unpin for SensorWorker
impl UnwindSafe for SensorWorker
Blanket Implementations§
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more