Expand description
Persisted workspace schema v1 with versioning and migration scaffolding.
A WorkspaceSnapshot wraps the pane tree snapshot with workspace-level
metadata, active pane tracking, and forward-compatible extension bags.
§Schema Versioning Policy
- Additive fields may be carried in
extensionsmaps without a version bump. - Breaking changes (field removal, semantic changes) require incrementing
WORKSPACE_SCHEMA_VERSIONand adding a migration path. - All snapshots carry their schema version; loaders reject unknown versions with actionable diagnostics.
§Usage
use ftui_layout::workspace::{WorkspaceSnapshot, WorkspaceMetadata, WORKSPACE_SCHEMA_VERSION};
use ftui_layout::pane::{PaneTreeSnapshot, PaneId, PaneNodeRecord, PaneLeaf, PANE_TREE_SCHEMA_VERSION};
use std::collections::BTreeMap;
let tree = PaneTreeSnapshot {
schema_version: PANE_TREE_SCHEMA_VERSION,
root: PaneId::default(),
next_id: PaneId::new(2).unwrap(),
nodes: vec![PaneNodeRecord::leaf(PaneId::default(), None, PaneLeaf::new("main"))],
extensions: BTreeMap::new(),
};
let snapshot = WorkspaceSnapshot::new(tree, WorkspaceMetadata::new("my-workspace"));
assert_eq!(snapshot.schema_version, WORKSPACE_SCHEMA_VERSION);
// Validate the snapshot
let result = snapshot.validate();
assert!(result.is_ok());Structs§
- Migration
Result - Result of attempting to migrate a workspace from an older schema version.
- Workspace
Metadata - Workspace metadata for provenance and diagnostics.
- Workspace
Snapshot - Persisted workspace state, wrapping a pane tree with metadata.
Enums§
- Workspace
Migration Error - Errors from workspace migration.
- Workspace
Validation Error - Errors from workspace validation.
Constants§
- WORKSPACE_
SCHEMA_ VERSION - Current workspace schema version.
Functions§
- migrate_
workspace - Attempt to migrate a workspace snapshot to the current schema version.
- needs_
migration - Check whether a snapshot requires migration.