diff --git a/demos/rust/.vscode/launch.json b/demos/rust/.vscode/launch.json index f996145..276c876 100644 --- a/demos/rust/.vscode/launch.json +++ b/demos/rust/.vscode/launch.json @@ -7,8 +7,18 @@ { "type": "lldb", "request": "launch", - "name": "Debug", - "program": "${workspaceFolder}/target/debug/rust_demo", + "name": "run rust demo", + "cargo": { + "args": [ + "build", + "--bin=rust_demo", + "--package=rust_demo", + ], + "filter": { + "name": "rust_demo", + "kind": "bin", + }, + }, "args": [], "cwd": "${workspaceFolder}" } diff --git a/demos/rust/.vscode/settings.json b/demos/rust/.vscode/settings.json new file mode 100644 index 0000000..62802c1 --- /dev/null +++ b/demos/rust/.vscode/settings.json @@ -0,0 +1,8 @@ +{ + "debugVisualizer.debugAdapterConfigurations": { + "lldb": { + "expressionTemplate": "${expr}", + "context": "watch" + } + } +} \ No newline at end of file diff --git a/demos/rust/src/main.rs b/demos/rust/src/main.rs index f52ba85..149ac3a 100644 --- a/demos/rust/src/main.rs +++ b/demos/rust/src/main.rs @@ -1,77 +1,77 @@ use serde::Serialize; -#[derive(Debug, Serialize)] -struct Label { - label: Option, -} -#[derive(Debug, Serialize)] -struct Row { - label: Option, - columns: Vec, -} -#[derive(Debug, Serialize)] -struct Column { - content: Option, - tag: Option, - color: Option, -} -#[derive(Debug, Serialize)] -struct Marker { - id: String, - row: u64, - column: u64, - rows: Option, - columns: Option, - label: Option, - color: Option, -} +// expected to mirror +// https://hediet.github.io/visualization/docs/visualization-data-schema.json +// +// implements the grid visualizer as an example -#[allow(clippy::trivially_copy_pass_by_ref)] -fn is_false(b: &bool) -> bool { - !*b -} - -#[derive(Debug, Serialize)] -struct Kind { - #[serde(skip_serializing_if = "is_false")] - array: bool, -} +pub type Label = String; +/// `GridVisualizationData` in schema #[derive(Debug, Serialize)] pub struct Grid { kind: Kind, - #[serde(rename = "columnLabels")] - column_labels: Option>, rows: Vec, - markers: Option>, + + #[serde(rename = "columnLabels")] + #[serde(skip_serializing_if="Option::is_none")] + column_labels: Option>, +} + +#[derive(Debug, Serialize)] +pub struct Kind { + grid: bool, +} + +#[derive(Debug, Serialize)] +pub struct Row { + columns: Vec, + + #[serde(skip_serializing_if="Option::is_none")] + label: Option