uni_plugin_host/host.rs
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2024-2026 Dragonscale Team
3
4//! Host callback surface.
5//!
6//! Some plugin-host engines (meta-plugin persistence, the background-job
7//! scheduler) need to run write-mode Cypher against the live database. Rather
8//! than reach back into the `uni-db` `Uni` internals (which would invert the
9//! crate dependency), they hold an [`HostCypherExecutor`] trait object that the
10//! `uni-db` API crate implements over its `UniInner` (open `Session` → `tx()`
11//! → `execute()` → `commit()`).
12
13/// Host-provided write-mode Cypher executor.
14///
15/// Implemented by the `uni-db` API crate. Best-effort callers (the persistence
16/// mirror) log and swallow the `Err`; the scheduler maps it to a plugin
17/// `FnError`. The current-thread-runtime guard / `block_in_place` handling
18/// lives in the host's implementation, not here.
19pub trait HostCypherExecutor: Send + Sync + std::fmt::Debug {
20 /// Execute a write-mode Cypher statement to commit.
21 fn execute_write_cypher(&self, cypher: &str) -> Result<(), String>;
22}