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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.