figma_api/models/
document_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 DocumentNode {
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    #[serde(rename = "children")]
50    pub children: Vec<models::CanvasNode>,
51}
52
53impl DocumentNode {
54    pub fn new(id: String, name: String, scroll_behavior: ScrollBehavior, children: Vec<models::CanvasNode>) -> DocumentNode {
55        DocumentNode {
56            id,
57            name,
58            visible: None,
59            locked: None,
60            is_fixed: None,
61            scroll_behavior,
62            rotation: None,
63            component_property_references: None,
64            plugin_data: None,
65            shared_plugin_data: None,
66            bound_variables: None,
67            explicit_variable_modes: None,
68            children,
69        }
70    }
71}
72/// How layer should be treated when the frame is resized
73#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
74pub enum ScrollBehavior {
75    #[serde(rename = "SCROLLS")]
76    Scrolls,
77    #[serde(rename = "FIXED")]
78    Fixed,
79    #[serde(rename = "STICKY_SCROLLS")]
80    StickyScrolls,
81}
82
83impl Default for ScrollBehavior {
84    fn default() -> ScrollBehavior {
85        Self::Scrolls
86    }
87}
88