[−][src]Crate interact_prompt
Interact Prompt
In high-level, to use Interact Prompt you need:
- Deriving of
Interact
over types. - Registration of state
- Spawning or invoking the Interact prompt.
In pseudo code:
ⓘThis example is not tested
extern crate interact; use interact::Interact; use interact_prompt::{LocalRegistry, SendRegistry, Settings}; #[derive(Interact)] struct YourType { // ... } // ... fn in_each_thread(rc: Rc<SomeState>) { // ... You would have some code to register your 'Rc's. LocalRegistry::insert("rc_state", Box::new(rc)); // ... } fn spawn_interact(arc: Arc<SomeOtherState>) { // On the global context you can register any object that is `Send` // and implements `Access` via #[derive(Interact)], this means `Arc` types, SendRegistry::insert("arc_state", Box::new(arc)); interact_prompt::spawn(Settings::default(), ()); }
NOTE: Currently only the SendRegistry
is supported for the background spawn
variant of
Interact. Supporting LocalRegistry is planned for the future.
Re-exports
pub use crate::registry::LocalRegistry; |
pub use crate::registry::SendRegistry; |
Modules
registry | Interact Prompt registry for accessible state. |
Structs
Settings |
Enums
Interaction | |
PromptError | |
Response |
Traits
Handler | This trait defines an optional handler for prompt commands. This allows to
override the behavior of the handler for |
Functions
direct | Use the current thread for an interactive |
spawn | Spawn |