Skip to main content

perspective_viewer/config/
options.rs

1// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
2// ┃ ██████ ██████ ██████       █      █      █      █      █ █▄  ▀███ █       ┃
3// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█  ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄  ▀█ █ ▀▀▀▀▀ ┃
4// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄   █ ▄▄▄▄▄ ┃
5// ┃ █      ██████ █  ▀█▄       █ ██████      █      ███▌▐███ ███████▄ █       ┃
6// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
7// ┃ Copyright (c) 2017, the Perspective Authors.                              ┃
8// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
9// ┃ This file is part of the Perspective library, distributed under the terms ┃
10// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
11// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
12
13//! Argument dictionaries for the public `PerspectiveViewerElement` methods.
14//! Each derives `ts_rs::TS` so its TypeScript type is generated (and
15//! re-exported from the crate's `typescript_custom_section`) alongside the
16//! config types, rather than hand-maintained.
17
18use serde::Deserialize;
19use ts_rs::TS;
20
21use crate::config::ExportMethod;
22
23/// Selects the target panel of a panel-scoped `<perspective-viewer>` method;
24/// the active panel when `panel` is omitted.
25#[derive(Deserialize, Default, TS)]
26pub struct PanelOptions {
27    #[ts(optional)]
28    pub panel: Option<String>,
29}
30
31/// The `eject` argument: the loaded client to remove by name; the active
32/// panel's client when omitted.
33#[derive(Deserialize, Default, TS)]
34pub struct ClientOptions {
35    #[ts(optional)]
36    pub client: Option<String>,
37}
38
39/// The `download` / `export` / `copy` argument: the `ExportMethod` and target
40/// panel.
41#[derive(Deserialize, Default, TS)]
42pub struct ExportOptions {
43    #[ts(as = "Option<ExportMethod>")]
44    #[ts(optional)]
45    pub method: Option<String>,
46
47    #[ts(optional)]
48    pub panel: Option<String>,
49}
50
51/// The `getTable` argument: whether to `wait` for a `Table`, and the target
52/// panel.
53#[derive(Deserialize, Default, TS)]
54pub struct GetTableOptions {
55    #[ts(optional)]
56    pub wait: Option<bool>,
57
58    #[ts(optional)]
59    pub panel: Option<String>,
60}
61
62/// The `getClient` argument: whether to `wait` for a `Client`, and the target
63/// panel.
64#[derive(Deserialize, Default, TS)]
65pub struct GetClientOptions {
66    #[ts(optional)]
67    pub wait: Option<bool>,
68
69    #[ts(optional)]
70    pub panel: Option<String>,
71}