pub struct StaticCompletionProvider { /* private fields */ }Expand description
Static completion provider with a fixed list of values.
ยงExamples
use pmcp::types::completable::{StaticCompletionProvider, CompletionItem, CompletionRequest, CompletionProviderTrait};
use std::collections::HashMap;
// Create from strings
let colors = StaticCompletionProvider::from_strings(vec![
"red".to_string(),
"green".to_string(),
"blue".to_string(),
]);
// Create with detailed items
let languages = StaticCompletionProvider::new(vec![
CompletionItem {
value: "rust".to_string(),
label: Some("Rust".to_string()),
description: Some("A systems programming language".to_string()),
icon: Some("๐ฆ".to_string()),
metadata: HashMap::new(),
},
CompletionItem {
value: "python".to_string(),
label: Some("Python".to_string()),
description: Some("A high-level programming language".to_string()),
icon: Some("๐".to_string()),
metadata: HashMap::new(),
},
]);
// Use the completion provider
let request = CompletionRequest {
argument: "language".to_string(),
partial: "r".to_string(),
context: HashMap::new(),
};
let response = languages.complete(request).await?;
assert!(!response.completions.is_empty());Implementationsยง
Sourceยงimpl StaticCompletionProvider
impl StaticCompletionProvider
Sourcepub fn new(items: Vec<CompletionItem>) -> Self
pub fn new(items: Vec<CompletionItem>) -> Self
Create a new static completion provider.
Sourcepub fn from_strings(values: Vec<String>) -> Self
pub fn from_strings(values: Vec<String>) -> Self
Create from a list of strings.
Trait Implementationsยง
Sourceยงimpl CompletionProviderTrait for StaticCompletionProvider
impl CompletionProviderTrait for StaticCompletionProvider
Sourceยงfn complete<'life0, 'async_trait>(
&'life0 self,
request: CompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<CompletionResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn complete<'life0, 'async_trait>(
&'life0 self,
request: CompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<CompletionResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get completions for an argument.
Auto Trait Implementationsยง
impl Freeze for StaticCompletionProvider
impl RefUnwindSafe for StaticCompletionProvider
impl Send for StaticCompletionProvider
impl Sync for StaticCompletionProvider
impl Unpin for StaticCompletionProvider
impl UnwindSafe for StaticCompletionProvider
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