2026-06-15 01:36:04 +03:00
|
|
|
//! # Open CAD Studio plugin API
|
|
|
|
|
//!
|
|
|
|
|
//! The stable, semver-versioned contract an add-on package targets instead of
|
|
|
|
|
//! the `OpenCADStudio` binary internals. It is intentionally **dependency
|
|
|
|
|
//! free** (no `iced`, no `acadrust`) so engine crates and external tooling can
|
|
|
|
|
//! depend on it cheaply.
|
|
|
|
|
//!
|
|
|
|
|
//! Two pieces live here:
|
|
|
|
|
//!
|
|
|
|
|
//! - [`manifest`] — plugin identity ([`PluginManifest`]) and the host ABI
|
|
|
|
|
//! version handshake ([`ApiVersion`]).
|
|
|
|
|
//! - [`ribbon`] — the [`CadModule`] trait and the plain-data ribbon types
|
|
|
|
|
//! ([`RibbonGroup`], [`ToolDef`], …) a plugin uses to describe its tab.
|
|
|
|
|
//!
|
|
|
|
|
//! The runtime host surface a plugin uses at *dispatch* time (document access,
|
2026-08-12 20:39:51 +02:00
|
|
|
//! command line, undo) is `acadrust`-typed and therefore lives in the `host`
|
|
|
|
|
//! feature; it re-exports `acadrust` so plugins do not need to depend on it
|
|
|
|
|
//! directly and risk an ABI mismatch from a different version.
|
|
|
|
|
//!
|
|
|
|
|
//! For binary compatibility, the host and every plugin must resolve the same
|
|
|
|
|
//! `acadrust` source. The host does this via a `[patch.crates-io]` entry in
|
|
|
|
|
//! `Cargo.toml`; out-of-tree plugins should copy that exact patch.
|
2026-08-27 00:14:08 +03:00
|
|
|
//!
|
|
|
|
|
//! For internal architecture (process model, wire protocols, versioning policy,
|
|
|
|
|
//! failure modes), see `ARCHITECTURE.md` in the crate root. The modules enabled
|
|
|
|
|
//! by the `host` feature are:
|
|
|
|
|
//!
|
|
|
|
|
//! - `host` — plugin/runtime traits and notification types.
|
|
|
|
|
//! - `host_v4` — per-tab shared-memory snapshot manager.
|
|
|
|
|
//! - `ipc` — transport, V2/V3 protocol, and V4 multiplexed protocol.
|
|
|
|
|
//! - `process` — `PluginProcess` and `PluginManager`.
|
|
|
|
|
//! - `runner` — child-process runner entry point.
|
|
|
|
|
//! - `shm` — shared-memory document views.
|
2026-06-15 01:36:04 +03:00
|
|
|
|
|
|
|
|
pub mod manifest;
|
|
|
|
|
pub mod ribbon;
|
2026-08-12 20:39:51 +02:00
|
|
|
pub mod type_registry;
|
|
|
|
|
pub mod type_registry_types;
|
|
|
|
|
pub mod version_info;
|
2026-06-15 01:36:04 +03:00
|
|
|
|
2026-06-17 11:31:05 +03:00
|
|
|
/// Runtime host surface — only built with the `host` feature (pulls `acadrust`).
|
|
|
|
|
#[cfg(feature = "host")]
|
|
|
|
|
pub mod host;
|
|
|
|
|
|
2026-08-12 20:39:51 +02:00
|
|
|
/// Host-side V4 snapshot manager — only built with the `host` feature.
|
|
|
|
|
#[cfg(feature = "host")]
|
|
|
|
|
pub mod host_v4;
|
|
|
|
|
|
2026-06-23 22:54:33 +02:00
|
|
|
/// Out-of-process plugin runtime — only built with the `host` feature.
|
|
|
|
|
#[cfg(feature = "host")]
|
|
|
|
|
pub mod ipc;
|
|
|
|
|
|
|
|
|
|
/// Process management for out-of-process plugins — only built with the `host`
|
|
|
|
|
/// feature.
|
|
|
|
|
#[cfg(feature = "host")]
|
|
|
|
|
pub mod process;
|
|
|
|
|
|
2026-06-24 16:34:27 +02:00
|
|
|
/// Shared-memory document view — only built with the `host` feature.
|
|
|
|
|
#[cfg(feature = "host")]
|
|
|
|
|
pub mod shm;
|
|
|
|
|
|
2026-06-23 22:54:33 +02:00
|
|
|
/// Plugin runner implementation used by the host when it spawns itself in
|
|
|
|
|
/// runner mode — only built with the `host` feature.
|
|
|
|
|
#[cfg(feature = "host")]
|
|
|
|
|
pub mod runner;
|
|
|
|
|
|
2026-06-24 17:17:36 +02:00
|
|
|
pub use manifest::{
|
2026-08-12 20:39:51 +02:00
|
|
|
effective_max_api_version, host_accepts_plugin_version, ApiVersion, PluginManifest,
|
|
|
|
|
API_VERSION, API_VERSION_MIN_SUPPORTED, MAX_API_VERSION_ENV,
|
2026-06-24 17:17:36 +02:00
|
|
|
};
|
2026-06-24 16:34:27 +02:00
|
|
|
pub use ribbon::{CadModule, IconKind, ModuleEvent, RibbonGroup, RibbonItem, StyleKey, ToolDef};
|
2026-08-12 20:39:51 +02:00
|
|
|
pub use type_registry::{
|
|
|
|
|
get_embedded_type_registry_json, EnumVariantInfo, FieldInfo, MethodInfo, ParameterInfo,
|
|
|
|
|
TypeId, TypeInfo, TypeKind, TypeRegistry,
|
|
|
|
|
};
|
|
|
|
|
pub use version_info::get_embedded_version_info_json;
|
2026-06-23 22:54:33 +02:00
|
|
|
|
2026-08-27 00:14:08 +03:00
|
|
|
#[cfg(test)]
|
|
|
|
|
pub(crate) mod test_lock {
|
|
|
|
|
//! Shared lock for tests that mutate process environment variables.
|
|
|
|
|
//!
|
|
|
|
|
//! Environment variables are global mutable state. Any test that sets or
|
|
|
|
|
//! removes an env var must hold this lock for the duration of the mutation
|
|
|
|
|
//! so tests in other modules do not observe half-written state.
|
|
|
|
|
pub static ENV_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(());
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-23 22:54:33 +02:00
|
|
|
#[cfg(feature = "host")]
|
2026-06-24 10:27:07 +02:00
|
|
|
pub use process::{DispatchResult, PluginError, PluginManager, PluginProcess};
|