Skip to main content

sqlite_graphrag/extract/
none_backend.rs

1//! No-op extraction backend (v1.0.75 — G21 auxiliary)
2//!
3//! Returns empty output for pipelines that want to skip extraction entirely.
4
5use super::{BackendHealth, BackendKind, ExtractionBackend, ExtractionHints, ExtractionOutput};
6use crate::errors::AppError;
7use async_trait::async_trait;
8
9/// None backend.
10pub struct NoneBackend;
11
12impl NoneBackend {
13    /// Create a new instance.
14    pub fn new() -> Self {
15        Self
16    }
17}
18
19impl Default for NoneBackend {
20    fn default() -> Self {
21        Self::new()
22    }
23}
24
25#[async_trait]
26impl ExtractionBackend for NoneBackend {
27    fn kind(&self) -> BackendKind {
28        BackendKind::None
29    }
30
31    fn model_name(&self) -> String {
32        "none".to_string()
33    }
34
35    async fn extract(
36        &self,
37        _content: &str,
38        _hints: &ExtractionHints,
39    ) -> Result<ExtractionOutput, AppError> {
40        Ok(ExtractionOutput {
41            backend: self.kind().as_str().to_string(),
42            elapsed_ms: 0,
43            ..Default::default()
44        })
45    }
46
47    async fn health(&self) -> Result<BackendHealth, AppError> {
48        Ok(BackendHealth {
49            kind: self.kind(),
50            healthy: true,
51            model_name: "none".to_string(),
52            message: "no-op backend always healthy".to_string(),
53        })
54    }
55}