avr_tester/components/
component_handle.rs1use super::*;
2use std::cell::RefCell;
3use std::rc::Rc;
4
5pub struct ComponentHandle {
6 state: Rc<RefCell<ComponentState>>,
7}
8
9impl ComponentHandle {
10 pub(crate) fn new(state: Rc<RefCell<ComponentState>>) -> Self {
11 Self { state }
12 }
13
14 pub fn pause(&self) {
16 *self.state.borrow_mut() = ComponentState::Paused;
17 }
18
19 pub fn resume(&self) {
21 *self.state.borrow_mut() = ComponentState::Working;
22 }
23
24 pub fn remove(self) {
26 *self.state.borrow_mut() = ComponentState::Removed;
27 }
28
29 pub fn state(&self) -> ComponentState {
31 *self.state.borrow()
32 }
33}