Skip to main content

Module workspace

Module workspace 

Source
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 extensions maps without a version bump.
  • Breaking changes (field removal, semantic changes) require incrementing WORKSPACE_SCHEMA_VERSION and 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§

MigrationResult
Result of attempting to migrate a workspace from an older schema version.
WorkspaceMetadata
Workspace metadata for provenance and diagnostics.
WorkspaceSnapshot
Persisted workspace state, wrapping a pane tree with metadata.

Enums§

WorkspaceMigrationError
Errors from workspace migration.
WorkspaceValidationError
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.