MCPcopy Create free account
hub / github.com/Autoparallel/learner / UserInteraction

Interface UserInteraction

crates/learnerd/src/interaction.rs:41–81  ·  view source on GitHub ↗

Trait for implementing user interactions. This trait defines the interface for handling user interactions. Implementations of this trait can provide different ways of interacting with users (CLI, TUI, API) while maintaining consistent behavior. The trait handles three main types of interactions: - Confirmation prompts (`confirm`) - Text input prompts (`prompt`) - Content display (`reply`)

Source from the content-addressed store, hash-verified

39/// - Text input prompts (`prompt`)
40/// - Content display (`reply`)
41pub trait UserInteraction {
42 /// Return back a mutable reference to an underlying `Learner` struct
43 fn learner(&mut self) -> &mut Learner;
44 /// Request confirmation from the user.
45 ///
46 /// # Arguments
47 ///
48 /// * `message` - The message to display in the confirmation prompt
49 ///
50 /// # Returns
51 ///
52 /// Returns `Ok(true)` if the user confirms, `Ok(false)` if they decline,
53 /// or an error if the interaction fails.
54 fn confirm(&mut self, message: &str) -> Result<bool>;
55
56 /// Request text input from the user.
57 ///
58 /// # Arguments
59 ///
60 /// * `message` - The prompt message to display to the user
61 ///
62 /// # Returns
63 ///
64 /// Returns the user's input as a String, or an error if the interaction fails.
65 fn prompt(&mut self, message: &str) -> Result<String>;
66
67 /// Display content to the user.
68 ///
69 /// This method handles formatting and displaying different types of content
70 /// defined in [`ResponseContent`].
71 ///
72 /// # Arguments
73 ///
74 /// * `content` - The content to display
75 ///
76 /// # Returns
77 ///
78 /// Returns `Ok(())` if the content was displayed successfully, or an error
79 /// if the display operation fails.
80 fn reply(&mut self, content: ResponseContent) -> Result<()>;
81}

Callers

nothing calls this directly

Implementers 2

mod.rscrates/learnerd/src/tui/mod.rs
mod.rscrates/learnerd/src/commands/mod.rs

Calls

no outgoing calls

Tested by

no test coverage detected