Expand description
Object Model for exposing terminal state to Fusabi scripts
This module provides handle-based proxies that allow Fusabi scripts to interact with Window, Pane, and Tab objects.
§Architecture
The object model uses a handle-based approach similar to WezTerm’s Lua API:
- Handles: Lightweight, copyable references to objects
- Registry: Centralized storage for objects with lifecycle management
- Generation Counters: Detect stale handles after object deletion
§Example
use scarab_plugin_api::object_model::{ObjectHandle, ObjectType, WindowProxy};
// Create a handle
let handle = ObjectHandle::new(ObjectType::Window, 1, 0);
// Create a proxy from the handle
let window = WindowProxy::new(handle).unwrap();
// Check validity
assert!(handle.is_valid(0));
assert!(!handle.is_valid(1));§Handle-Based Design
Instead of passing raw object references to scripts, we use handles:
- Safety: Scripts can’t hold dangling references
- Serialization: Handles can cross process boundaries
- Invalidation: Generation counters detect deleted objects
- Type Safety: ObjectType enum prevents type confusion
§Lifecycle Management
Objects follow this lifecycle:
- Registration: Object is stored, handle is returned
- Access: Handle is used to retrieve object from registry
- Unregistration: Object is removed, generation is incremented
- Invalidation: Old handles fail validation checks
§Thread Safety
All types in this module are designed to be Send + Sync:
- Handles contain only primitive types
- Registry trait can be implemented with appropriate locking
- Errors are cloneable for propagation across threads
Structs§
- Object
Handle - A handle to an object managed by the object registry
- Pane
Proxy - Proxy for a terminal pane
- Registry
Entry - Entry in the object registry containing the object and its handle
- TabProxy
- Proxy for a terminal tab
- Window
Proxy - Proxy for a terminal window
Enums§
- Object
Error - Errors that can occur when working with the object model
- Object
Type - Type of object this handle references
Traits§
- Object
Registry - Trait for managing object lifecycle in a registry
Type Aliases§
- Result
- Result type alias for object model operations