pub trait Provider {
// Required methods
fn new(config: &PluginConfigAdapter<'_>) -> Self;
fn query(&self, query: &str) -> ProviderResult;
// Provided method
fn clear_caches(&self) { ... }
}
Expand description
Abstracts functionality required for a provider.
Implement this and add the crate::gravel_provider
macro to write a provider plugin:
use gravel_ffi::prelude::*;
pub struct MyProvider {
// put state here
}
// give the plugin a memorable name
#[gravel_provider("my_provider")]
impl Provider for MyProvider {
fn new(config: &PluginConfigAdapter<'_>) -> Self {
Self { }
}
fn query(&self, query: &str) -> ProviderResult {
ProviderResult::empty()
}
}
Required Methods§
sourcefn new(config: &PluginConfigAdapter<'_>) -> Self
fn new(config: &PluginConfigAdapter<'_>) -> Self
Constructs a new provider.
sourcefn query(&self, query: &str) -> ProviderResult
fn query(&self, query: &str) -> ProviderResult
Queries the provider and returns hits.
Provided Methods§
sourcefn clear_caches(&self)
fn clear_caches(&self)
Clears all caches the provider may keep.
Object Safety§
This trait is not object safe.