figma_api/models/
canvas_node.rs

1/*
2 * Figma API
3 *
4 * This is the OpenAPI specification for the [Figma REST API](https://www.figma.com/developers/api).  Note: we are releasing the OpenAPI specification as a beta given the large surface area and complexity of the REST API. If you notice any inaccuracies with the specification, please [file an issue](https://github.com/figma/rest-api-spec/issues).
5 *
6 * The version of the OpenAPI document: 0.31.0
7 * Contact: support@figma.com
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15pub struct CanvasNode {
16    /// A string uniquely identifying this node within the document.
17    #[serde(rename = "id")]
18    pub id: String,
19    /// The name given to the node by the user in the tool.
20    #[serde(rename = "name")]
21    pub name: String,
22    /// Whether or not the node is visible on the canvas.
23    #[serde(rename = "visible", skip_serializing_if = "Option::is_none")]
24    pub visible: Option<bool>,
25    /// If true, layer is locked and cannot be edited
26    #[serde(rename = "locked", skip_serializing_if = "Option::is_none")]
27    pub locked: Option<bool>,
28    /// Whether the layer is fixed while the parent is scrolling
29    #[serde(rename = "isFixed", skip_serializing_if = "Option::is_none")]
30    pub is_fixed: Option<bool>,
31    /// How layer should be treated when the frame is resized
32    #[serde(rename = "scrollBehavior")]
33    pub scroll_behavior: ScrollBehavior,
34    /// The rotation of the node, if not 0.
35    #[serde(rename = "rotation", skip_serializing_if = "Option::is_none")]
36    pub rotation: Option<f64>,
37    /// A mapping of a layer's property to component property name of component properties attached to this node. The component property name can be used to look up more information on the corresponding component's or component set's componentPropertyDefinitions.
38    #[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    /// A mapping of variable collection ID to mode ID representing the explicitly set modes for this node.
47    #[serde(rename = "explicitVariableModes", skip_serializing_if = "Option::is_none")]
48    pub explicit_variable_modes: Option<std::collections::HashMap<String, String>>,
49    /// An array of export settings representing images to export from the node.
50    #[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    /// Background color of the canvas.
55    #[serde(rename = "backgroundColor")]
56    pub background_color: Box<models::Rgba>,
57    /// Node ID that corresponds to the start frame for prototypes. This is deprecated with the introduction of multiple flows. Please use the `flowStartingPoints` field.
58    #[serde(rename = "prototypeStartNodeID", deserialize_with = "Option::deserialize")]
59    pub prototype_start_node_id: Option<String>,
60    /// An array of flow starting points sorted by its position in the prototype settings panel.
61    #[serde(rename = "flowStartingPoints")]
62    pub flow_starting_points: Vec<models::FlowStartingPoint>,
63    /// The device used to view a prototype.
64    #[serde(rename = "prototypeDevice")]
65    pub prototype_device: Box<models::PrototypeDevice>,
66    /// The background color of the prototype (currently only supports a single solid color paint).
67    #[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/// How layer should be treated when the frame is resized
100#[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