Skip to main content

scrybe_core/
plugin.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 Shawn Hartsock and contributors
3
4//! Plugin trait — the extension point for Python and native plugins.
5
6use crate::document::Document;
7use crate::error::Result;
8
9/// A Scrybe plugin can observe and transform documents.
10///
11/// Implementations live in `scrybe-py` (PyO3 bindings) and in native
12/// Rust for first-party extensions. The `scrybe-app` frontend invokes
13/// plugins via `scrybe-panels` (P3.3).
14pub trait Plugin: Send + Sync {
15    /// Human-readable plugin name.
16    fn name(&self) -> &str;
17
18    /// Called when a document is opened or modified.
19    ///
20    /// Returns an optionally transformed document. Return `None` to
21    /// pass through unchanged.
22    fn on_change(&self, doc: &Document) -> Result<Option<Document>>;
23}