mockforge_plugin_core/
async_trait.rs

1//! Async Token Resolver Trait Definition
2//!
3//! This module defines the async trait for token resolvers,
4//! providing a proper async interface for plugin-based token resolution.
5
6use crate::types::{PluginError, PluginMetadata, ResolutionContext};
7use async_trait::async_trait;
8
9/// Async token resolver trait for plugins
10#[async_trait]
11pub trait TokenResolver: Send + Sync {
12    /// Check if this resolver can handle a given token
13    fn can_resolve(&self, token: &str) -> bool;
14
15    /// Resolve a token to its value asynchronously
16    async fn resolve_token(
17        &self,
18        token: &str,
19        context: &ResolutionContext,
20    ) -> Result<String, PluginError>;
21
22    /// Get plugin metadata
23    fn get_metadata(&self) -> PluginMetadata;
24
25    /// Validate plugin configuration
26    fn validate(&self) -> Result<(), PluginError> {
27        Ok(())
28    }
29}
30#[cfg(test)]
31mod tests {
32    use super::*;
33
34    #[test]
35    fn test_trait_definition() {
36        // Test that the trait exists and can be referenced
37        let _ = std::marker::PhantomData::<&dyn TokenResolver>;
38    }
39}