Common/TreeView/DTO/
TreeItemDTO.rs

1//! # TreeItemDTO
2//!
3//! Defines the Data Transfer Object for a single item in a tree view.
4
5use serde::{Deserialize, Serialize};
6use serde_json::Value;
7
8/// A serializable struct that represents a `vscode.TreeItem`.
9///
10/// This DTO is sent from `Cocoon` (where the `TreeDataProvider` logic lives)
11/// to `Mountain` (where the UI state is managed) to describe how to render an
12/// item in a tree view. It uses `serde_json::Value` for complex properties to
13/// maintain flexibility and compatibility with the VS Code API.
14#[derive(Serialize, Deserialize, Debug, Clone)]
15#[serde(rename_all = "PascalCase")]
16pub struct TreeItemDTO {
17	/// A unique handle for this item within its tree view, generated by Cocoon.
18	pub Handle:String,
19
20	/// The handle of the parent item, if any.
21	#[serde(skip_serializing_if = "Option::is_none")]
22	pub ParentHandle:Option<String>,
23
24	/// The label for the tree item. Can be a simple string or a
25	/// `TreeItemLabel` object for highlighting.
26	#[serde(skip_serializing_if = "Option::is_none")]
27	pub Label:Option<Value>,
28
29	/// A human-readable description for the tree item.
30	#[serde(skip_serializing_if = "Option::is_none")]
31	pub Description:Option<String>,
32
33	/// The URI of the resource represented by this item. Serialized
34	/// `UriComponents`.
35	#[serde(skip_serializing_if = "Option::is_none")]
36	pub ResourceURI:Option<Value>,
37
38	/// The tooltip to show when hovering over the item. Serialized `string` or
39	/// `IMarkdownStringDTO`.
40	#[serde(skip_serializing_if = "Option::is_none")]
41	pub Tooltip:Option<Value>,
42
43	/// The command to execute when the item is selected. Serialized
44	/// `CommandDTO`.
45	#[serde(skip_serializing_if = "Option::is_none")]
46	pub Command:Option<Value>,
47
48	/// The collapsible state of the item (e.g., None, Collapsed, Expanded).
49	/// Corresponds to `vscode.TreeItemCollapsibleState`.
50	pub CollapsibleState:u32,
51
52	/// A string that can be used for context-menu visibility (`when` clauses).
53	#[serde(skip_serializing_if = "Option::is_none")]
54	pub ContextValue:Option<String>,
55
56	/// A path to an icon or a light/dark pair of paths. Serialized
57	/// `UriComponents`.
58	#[serde(skip_serializing_if = "Option::is_none")]
59	pub Icon:Option<Value>,
60
61	/// A `ThemeIcon` identifier (e.g., 'file-code'). Serialized `ThemeIcon`.
62	#[serde(skip_serializing_if = "Option::is_none")]
63	pub ThemeIcon:Option<Value>,
64
65	/// The state of a checkbox displayed next to the tree item, if any.
66	/// Serialized `CheckboxState`.
67	#[serde(skip_serializing_if = "Option::is_none")]
68	pub CheckboxState:Option<Value>,
69}