figma_api/models/
constraint.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/// Constraint : Sizing constraint for exports.
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct Constraint {
17    /// Type of constraint to apply:  - `SCALE`: Scale by `value`. - `WIDTH`: Scale proportionally and set width to `value`. - `HEIGHT`: Scale proportionally and set height to `value`.
18    #[serde(rename = "type")]
19    pub r#type: Type,
20    /// See type property for effect of this field.
21    #[serde(rename = "value")]
22    pub value: f64,
23}
24
25impl Constraint {
26    /// Sizing constraint for exports.
27    pub fn new(r#type: Type, value: f64) -> Constraint {
28        Constraint {
29            r#type,
30            value,
31        }
32    }
33}
34/// Type of constraint to apply:  - `SCALE`: Scale by `value`. - `WIDTH`: Scale proportionally and set width to `value`. - `HEIGHT`: Scale proportionally and set height to `value`.
35#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
36pub enum Type {
37    #[serde(rename = "SCALE")]
38    Scale,
39    #[serde(rename = "WIDTH")]
40    Width,
41    #[serde(rename = "HEIGHT")]
42    Height,
43}
44
45impl Default for Type {
46    fn default() -> Type {
47        Self::Scale
48    }
49}
50