fixed generics

This commit is contained in:
Priec
2025-08-02 00:19:45 +02:00
parent 643db8e586
commit 2b08e64db8
2 changed files with 59 additions and 72 deletions

View File

@@ -8,23 +8,23 @@ use async_trait::async_trait;
pub trait DataProvider {
/// How many fields in the form
fn field_count(&self) -> usize;
/// Get field label/name
fn field_name(&self, index: usize) -> &str;
/// Get field value
/// Get field value
fn field_value(&self, index: usize) -> &str;
/// Set field value (library calls this when text changes)
fn set_field_value(&mut self, index: usize, value: String);
/// Check if field supports autocomplete (optional)
fn supports_autocomplete(&self, _field_index: usize) -> bool {
false
}
/// Get display value (for password masking, etc.) - optional
fn display_value(&self, index: usize) -> Option<&str> {
fn display_value(&self, _index: usize) -> Option<&str> {
None // Default: use actual value
}
}
@@ -32,16 +32,13 @@ pub trait DataProvider {
/// Optional: User implements this for autocomplete data
#[async_trait]
pub trait AutocompleteProvider {
type SuggestionData: Clone + Send + 'static;
/// Fetch autocomplete suggestions (user's business logic)
async fn fetch_suggestions(&mut self, field_index: usize, query: &str)
-> Result<Vec<SuggestionItem<Self::SuggestionData>>>;
async fn fetch_suggestions(&mut self, field_index: usize, query: &str)
-> Result<Vec<SuggestionItem>>;
}
#[derive(Debug, Clone)]
pub struct SuggestionItem<T> {
pub data: T,
pub struct SuggestionItem {
pub display_text: String,
pub value_to_store: String,
}