forked from 1b-agent/opencadstudio-upstream
Add the typed document facade and plugin IPC adapter. Prepare bulk edits before mutation, preserve undo and dirty state, keep profile elevations, validate numeric inputs and session bindings, and generate Python constructors with typed results. Reuse existing entity transforms and profile conversion. Compute mass properties and closed-surface bounds in cadkernel; pin its main revision 6a5e6fc2822f6af6b2611cd605b44437b35158f0. Keep plugin API metadata at version 6. Validation: 646 native application tests, 597 kernel tests, 12 document API tests, 91 plugin API tests, 3 Python tests, default/IPC feature builds and wasm32 check passed.
37 lines
1.1 KiB
Rust
37 lines
1.1 KiB
Rust
//! Stable entity identity.
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
/// A stable u64 handle to a first-level document entity, decoupled from any
|
|
/// internal engine/kernel pointer. Value-compatible with `acadrust::Handle` —
|
|
/// kernel keys never cross the API boundary.
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
|
|
#[serde(transparent)]
|
|
pub struct ObjectId(pub u64);
|
|
|
|
impl ObjectId {
|
|
/// The null / absent handle (`acadrust::Handle::NULL` value `0`).
|
|
pub const NULL: ObjectId = ObjectId(0);
|
|
|
|
pub const fn as_u64(self) -> u64 {
|
|
self.0
|
|
}
|
|
|
|
/// Build from a raw u64 (e.g. an `acadrust::Handle`'s value).
|
|
pub const fn from_u64(v: u64) -> Self {
|
|
Self(v)
|
|
}
|
|
|
|
/// Build from an `acadrust::Handle` (host/ipc feature).
|
|
#[cfg(any(feature = "host", feature = "ipc"))]
|
|
pub fn from_handle(h: acadrust::Handle) -> Self {
|
|
Self(h.value())
|
|
}
|
|
|
|
/// Convert to an `acadrust::Handle` (host/ipc feature).
|
|
#[cfg(any(feature = "host", feature = "ipc"))]
|
|
pub fn to_handle(self) -> acadrust::Handle {
|
|
acadrust::Handle::new(self.0)
|
|
}
|
|
}
|