figma_api/models/
local_variable.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/// LocalVariable : A Variable is a single design token that defines values for each of the modes in its VariableCollection. These values can be applied to various kinds of design properties.
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct LocalVariable {
17    /// The unique identifier of this variable.
18    #[serde(rename = "id")]
19    pub id: String,
20    /// The name of this variable.
21    #[serde(rename = "name")]
22    pub name: String,
23    /// The key of this variable.
24    #[serde(rename = "key")]
25    pub key: String,
26    /// The id of the variable collection that contains this variable.
27    #[serde(rename = "variableCollectionId")]
28    pub variable_collection_id: String,
29    /// The resolved type of the variable.
30    #[serde(rename = "resolvedType")]
31    pub resolved_type: ResolvedType,
32    /// The values for each mode of this variable.
33    #[serde(rename = "valuesByMode")]
34    pub values_by_mode: std::collections::HashMap<String, models::LocalVariableValuesByModeValue>,
35    /// Whether this variable is remote.
36    #[serde(rename = "remote")]
37    pub remote: bool,
38    /// The description of this variable.
39    #[serde(rename = "description")]
40    pub description: String,
41    /// Whether this variable is hidden when publishing the current file as a library.  If the parent `VariableCollection` is marked as `hiddenFromPublishing`, then this variable will also be hidden from publishing via the UI. `hiddenFromPublishing` is independently toggled for a variable and collection. However, both must be true for a given variable to be publishable.
42    #[serde(rename = "hiddenFromPublishing")]
43    pub hidden_from_publishing: bool,
44    /// An array of scopes in the UI where this variable is shown. Setting this property will show/hide this variable in the variable picker UI for different fields.  Setting scopes for a variable does not prevent that variable from being bound in other scopes (for example, via the Plugin API). This only limits the variables that are shown in pickers within the Figma UI.
45    #[serde(rename = "scopes")]
46    pub scopes: Vec<models::VariableScope>,
47    #[serde(rename = "codeSyntax")]
48    pub code_syntax: Box<models::VariableCodeSyntax>,
49    /// Indicates that the variable was deleted in the editor, but the document may still contain references to the variable. References to the variable may exist through bound values or variable aliases.
50    #[serde(rename = "deletedButReferenced", skip_serializing_if = "Option::is_none")]
51    pub deleted_but_referenced: Option<bool>,
52}
53
54impl LocalVariable {
55    /// A Variable is a single design token that defines values for each of the modes in its VariableCollection. These values can be applied to various kinds of design properties.
56    pub fn new(id: String, name: String, key: String, variable_collection_id: String, resolved_type: ResolvedType, values_by_mode: std::collections::HashMap<String, models::LocalVariableValuesByModeValue>, remote: bool, description: String, hidden_from_publishing: bool, scopes: Vec<models::VariableScope>, code_syntax: models::VariableCodeSyntax) -> LocalVariable {
57        LocalVariable {
58            id,
59            name,
60            key,
61            variable_collection_id,
62            resolved_type,
63            values_by_mode,
64            remote,
65            description,
66            hidden_from_publishing,
67            scopes,
68            code_syntax: Box::new(code_syntax),
69            deleted_but_referenced: None,
70        }
71    }
72}
73/// The resolved type of the variable.
74#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
75pub enum ResolvedType {
76    #[serde(rename = "BOOLEAN")]
77    Boolean,
78    #[serde(rename = "FLOAT")]
79    Float,
80    #[serde(rename = "STRING")]
81    String,
82    #[serde(rename = "COLOR")]
83    Color,
84}
85
86impl Default for ResolvedType {
87    fn default() -> ResolvedType {
88        Self::Boolean
89    }
90}
91