Skip to main content

Prompt

Trait Prompt 

Source
pub trait Prompt: Send + Sync {
    type PromptError: Error + Send + Sync;

    // Required method
    fn prompt(
        &self,
        prompt: &str,
    ) -> impl Future<Output = Result<String, Self::PromptError>> + Send;
}
Expand description

A trait representing a prompt-based interaction mechanism.

This trait defines the behavior of components that process user prompts and return responses asynchronously.

§Associated Types

  • PromptError: Represents errors that may occur during prompt processing.

§Requirements

Implementors of this trait must ensure thread safety (Send and Sync) and provide an asynchronous implementation for the prompt method.

Required Associated Types§

Source

type PromptError: Error + Send + Sync

The error type associated with the prompt operation.

Required Methods§

Source

fn prompt( &self, prompt: &str, ) -> impl Future<Output = Result<String, Self::PromptError>> + Send

Processes the given prompt and returns a response asynchronously.

§Arguments
  • prompt: The input string provided by the user.
§Returns

A future that resolves to either:

  • Ok(String): The generated response as a string.
  • Err(Self::PromptError): An error that occurred during prompt processing.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§