Trait gravel_ffi::Provider

source ·
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§

source

fn new(config: &PluginConfigAdapter<'_>) -> Self

Constructs a new provider.

source

fn query(&self, query: &str) -> ProviderResult

Queries the provider and returns hits.

Provided Methods§

source

fn clear_caches(&self)

Clears all caches the provider may keep.

Object Safety§

This trait is not object safe.

Implementors§