figma_api/models/
canvas_node.rs1use crate::models;
12use serde::{Deserialize, Serialize};
13
14#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15pub struct CanvasNode {
16 #[serde(rename = "id")]
18 pub id: String,
19 #[serde(rename = "name")]
21 pub name: String,
22 #[serde(rename = "visible", skip_serializing_if = "Option::is_none")]
24 pub visible: Option<bool>,
25 #[serde(rename = "locked", skip_serializing_if = "Option::is_none")]
27 pub locked: Option<bool>,
28 #[serde(rename = "isFixed", skip_serializing_if = "Option::is_none")]
30 pub is_fixed: Option<bool>,
31 #[serde(rename = "scrollBehavior")]
33 pub scroll_behavior: ScrollBehavior,
34 #[serde(rename = "rotation", skip_serializing_if = "Option::is_none")]
36 pub rotation: Option<f64>,
37 #[serde(rename = "componentPropertyReferences", skip_serializing_if = "Option::is_none")]
39 pub component_property_references: Option<std::collections::HashMap<String, String>>,
40 #[serde(rename = "pluginData", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
41 pub plugin_data: Option<Option<serde_json::Value>>,
42 #[serde(rename = "sharedPluginData", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
43 pub shared_plugin_data: Option<Option<serde_json::Value>>,
44 #[serde(rename = "boundVariables", skip_serializing_if = "Option::is_none")]
45 pub bound_variables: Option<Box<models::IsLayerTraitBoundVariables>>,
46 #[serde(rename = "explicitVariableModes", skip_serializing_if = "Option::is_none")]
48 pub explicit_variable_modes: Option<std::collections::HashMap<String, String>>,
49 #[serde(rename = "exportSettings", skip_serializing_if = "Option::is_none")]
51 pub export_settings: Option<Vec<models::ExportSetting>>,
52 #[serde(rename = "children")]
53 pub children: Vec<models::SubcanvasNode>,
54 #[serde(rename = "backgroundColor")]
56 pub background_color: Box<models::Rgba>,
57 #[serde(rename = "prototypeStartNodeID", deserialize_with = "Option::deserialize")]
59 pub prototype_start_node_id: Option<String>,
60 #[serde(rename = "flowStartingPoints")]
62 pub flow_starting_points: Vec<models::FlowStartingPoint>,
63 #[serde(rename = "prototypeDevice")]
65 pub prototype_device: Box<models::PrototypeDevice>,
66 #[serde(rename = "prototypeBackgrounds", skip_serializing_if = "Option::is_none")]
68 pub prototype_backgrounds: Option<Vec<models::Rgba>>,
69 #[serde(rename = "measurements", skip_serializing_if = "Option::is_none")]
70 pub measurements: Option<Vec<models::Measurement>>,
71}
72
73impl CanvasNode {
74 pub fn new(id: String, name: String, scroll_behavior: ScrollBehavior, children: Vec<models::SubcanvasNode>, background_color: models::Rgba, prototype_start_node_id: Option<String>, flow_starting_points: Vec<models::FlowStartingPoint>, prototype_device: models::PrototypeDevice) -> CanvasNode {
75 CanvasNode {
76 id,
77 name,
78 visible: None,
79 locked: None,
80 is_fixed: None,
81 scroll_behavior,
82 rotation: None,
83 component_property_references: None,
84 plugin_data: None,
85 shared_plugin_data: None,
86 bound_variables: None,
87 explicit_variable_modes: None,
88 export_settings: None,
89 children,
90 background_color: Box::new(background_color),
91 prototype_start_node_id,
92 flow_starting_points,
93 prototype_device: Box::new(prototype_device),
94 prototype_backgrounds: None,
95 measurements: None,
96 }
97 }
98}
99#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
101pub enum ScrollBehavior {
102 #[serde(rename = "SCROLLS")]
103 Scrolls,
104 #[serde(rename = "FIXED")]
105 Fixed,
106 #[serde(rename = "STICKY_SCROLLS")]
107 StickyScrolls,
108}
109
110impl Default for ScrollBehavior {
111 fn default() -> ScrollBehavior {
112 Self::Scrolls
113 }
114}
115