Skip to main content

guise/panegroup/
id.rs

1//! Stable opaque identifiers for panes and splits.
2
3/// Identifies a pane. Allocate via [`PaneIds`].
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
5pub struct PaneId(pub(crate) u64);
6
7/// Identifies a split node (a divider) inside a [`super::PaneTree`].
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
9pub struct SplitId(pub(crate) u64);
10
11/// Identifies a tab item (a terminal/webview) held inside a [`super::Pane`].
12/// Allocate via [`ItemIds`]. Items are the unit that moves between panes.
13#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct ItemId(pub(crate) u64);
15
16/// Monotonic [`ItemId`] allocator. Owned by the caller; never reuses ids.
17#[derive(Debug, Default, Clone)]
18pub struct ItemIds(u64);
19
20impl ItemIds {
21    pub fn new() -> Self {
22        Self::default()
23    }
24
25    pub fn next(&mut self) -> ItemId {
26        self.0 += 1;
27        ItemId(self.0)
28    }
29}
30
31/// Monotonic [`PaneId`] allocator. Owned by the caller; never reuses ids.
32#[derive(Debug, Default, Clone)]
33pub struct PaneIds(u64);
34
35impl PaneIds {
36    pub fn new() -> Self {
37        Self::default()
38    }
39
40    pub fn next(&mut self) -> PaneId {
41        self.0 += 1;
42        PaneId(self.0)
43    }
44}