pub struct UserInputHandler {
channels: Mutex<HashMap<String, Sender<UserInputResponse>>>,
}Expand description
Registry for pending user input requests. Routes responses from the frontend back to waiting async tasks.
Fields§
§channels: Mutex<HashMap<String, Sender<UserInputResponse>>>Implementations§
Source§impl UserInputHandler
impl UserInputHandler
pub fn new() -> Self
Sourcepub fn register(&self, request_id: &str) -> Receiver<UserInputResponse>
pub fn register(&self, request_id: &str) -> Receiver<UserInputResponse>
Register a new user input request. Returns the request ID and a receiver for the response.
Sourcepub fn deliver(&self, response: UserInputResponse) -> Result<(), String>
pub fn deliver(&self, response: UserInputResponse) -> Result<(), String>
Deliver a response from the frontend. Returns error if no pending request with the given ID.
Sourcepub fn cancel(&self, request_id: &str)
pub fn cancel(&self, request_id: &str)
Cancel a pending request (removes it from the registry).
Sourcepub fn has_pending(&self, request_id: &str) -> bool
pub fn has_pending(&self, request_id: &str) -> bool
Check if there’s a pending request with the given ID.
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
Get count of pending requests.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for UserInputHandler
impl RefUnwindSafe for UserInputHandler
impl Send for UserInputHandler
impl Sync for UserInputHandler
impl Unpin for UserInputHandler
impl UnwindSafe for UserInputHandler
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.