/*
* Figma API
*
* 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).
*
* The version of the OpenAPI document: 0.31.0
* Contact: support@figma.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct ConnectorNode {
/// A string uniquely identifying this node within the document.
#[serde(rename = "id")]
pub id: String,
/// The name given to the node by the user in the tool.
#[serde(rename = "name")]
pub name: String,
/// Whether or not the node is visible on the canvas.
#[serde(rename = "visible", skip_serializing_if = "Option::is_none")]
pub visible: Option<bool>,
/// If true, layer is locked and cannot be edited
#[serde(rename = "locked", skip_serializing_if = "Option::is_none")]
pub locked: Option<bool>,
/// Whether the layer is fixed while the parent is scrolling
#[serde(rename = "isFixed", skip_serializing_if = "Option::is_none")]
pub is_fixed: Option<bool>,
/// How layer should be treated when the frame is resized
#[serde(rename = "scrollBehavior")]
pub scroll_behavior: ScrollBehavior,
/// The rotation of the node, if not 0.
#[serde(rename = "rotation", skip_serializing_if = "Option::is_none")]
pub rotation: Option<f64>,
/// 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.
#[serde(rename = "componentPropertyReferences", skip_serializing_if = "Option::is_none")]
pub component_property_references: Option<std::collections::HashMap<String, String>>,
#[serde(rename = "pluginData", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub plugin_data: Option<Option<serde_json::Value>>,
#[serde(rename = "sharedPluginData", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub shared_plugin_data: Option<Option<serde_json::Value>>,
#[serde(rename = "boundVariables", skip_serializing_if = "Option::is_none")]
pub bound_variables: Option<Box<models::IsLayerTraitBoundVariables>>,
/// A mapping of variable collection ID to mode ID representing the explicitly set modes for this node.
#[serde(rename = "explicitVariableModes", skip_serializing_if = "Option::is_none")]
pub explicit_variable_modes: Option<std::collections::HashMap<String, String>>,
/// Keep height and width constrained to same ratio.
#[serde(rename = "preserveRatio", skip_serializing_if = "Option::is_none")]
pub preserve_ratio: Option<bool>,
/// Horizontal and vertical layout constraints for node.
#[serde(rename = "constraints", skip_serializing_if = "Option::is_none")]
pub constraints: Option<Box<models::LayoutConstraint>>,
/// A transformation matrix is standard way in computer graphics to represent translation and rotation. These are the top two rows of a 3x3 matrix. The bottom row of the matrix is assumed to be [0, 0, 1]. This is known as an affine transform and is enough to represent translation, rotation, and skew. The identity transform is [[1, 0, 0], [0, 1, 0]]. A translation matrix will typically look like: ``` [[1, 0, tx], [0, 1, ty]] ``` and a rotation matrix will typically look like: ``` [[cos(angle), sin(angle), 0], [-sin(angle), cos(angle), 0]] ``` Another way to think about this transform is as three vectors: - The x axis (t[0][0], t[1][0]) - The y axis (t[0][1], t[1][1]) - The translation offset (t[0][2], t[1][2]) The most common usage of the Transform matrix is the `relativeTransform property`. This particular usage of the matrix has a few additional restrictions. The translation offset can take on any value but we do enforce that the axis vectors are unit vectors (i.e. have length 1). The axes are not required to be at 90° angles to each other.
#[serde(rename = "relativeTransform", skip_serializing_if = "Option::is_none")]
pub relative_transform: Option<Vec<Vec<f64>>>,
/// Width and height of element. This is different from the width and height of the bounding box in that the absolute bounding box represents the element after scaling and rotation. Only present if `geometry=paths` is passed.
#[serde(rename = "size", skip_serializing_if = "Option::is_none")]
pub size: Option<Box<models::Vector>>,
/// Determines if the layer should stretch along the parent's counter axis. This property is only provided for direct children of auto-layout frames. - `INHERIT` - `STRETCH` In previous versions of auto layout, determined how the layer is aligned inside an auto-layout frame. This property is only provided for direct children of auto-layout frames. - `MIN` - `CENTER` - `MAX` - `STRETCH` In horizontal auto-layout frames, \"MIN\" and \"MAX\" correspond to \"TOP\" and \"BOTTOM\". In vertical auto-layout frames, \"MIN\" and \"MAX\" correspond to \"LEFT\" and \"RIGHT\".
#[serde(rename = "layoutAlign", skip_serializing_if = "Option::is_none")]
pub layout_align: Option<LayoutAlign>,
/// This property is applicable only for direct children of auto-layout frames, ignored otherwise. Determines whether a layer should stretch along the parent's primary axis. A `0` corresponds to a fixed size and `1` corresponds to stretch.
#[serde(rename = "layoutGrow", skip_serializing_if = "Option::is_none")]
pub layout_grow: Option<f64>,
/// Determines whether a layer's size and position should be determined by auto-layout settings or manually adjustable.
#[serde(rename = "layoutPositioning", skip_serializing_if = "Option::is_none")]
pub layout_positioning: Option<LayoutPositioning>,
/// The minimum width of the frame. This property is only applicable for auto-layout frames or direct children of auto-layout frames.
#[serde(rename = "minWidth", skip_serializing_if = "Option::is_none")]
pub min_width: Option<f64>,
/// The maximum width of the frame. This property is only applicable for auto-layout frames or direct children of auto-layout frames.
#[serde(rename = "maxWidth", skip_serializing_if = "Option::is_none")]
pub max_width: Option<f64>,
/// The minimum height of the frame. This property is only applicable for auto-layout frames or direct children of auto-layout frames.
#[serde(rename = "minHeight", skip_serializing_if = "Option::is_none")]
pub min_height: Option<f64>,
/// The maximum height of the frame. This property is only applicable for auto-layout frames or direct children of auto-layout frames.
#[serde(rename = "maxHeight", skip_serializing_if = "Option::is_none")]
pub max_height: Option<f64>,
/// The horizontal sizing setting on this auto-layout frame or frame child. - `FIXED` - `HUG`: only valid on auto-layout frames and text nodes - `FILL`: only valid on auto-layout frame children
#[serde(rename = "layoutSizingHorizontal", skip_serializing_if = "Option::is_none")]
pub layout_sizing_horizontal: Option<LayoutSizingHorizontal>,
/// The vertical sizing setting on this auto-layout frame or frame child. - `FIXED` - `HUG`: only valid on auto-layout frames and text nodes - `FILL`: only valid on auto-layout frame children
#[serde(rename = "layoutSizingVertical", skip_serializing_if = "Option::is_none")]
pub layout_sizing_vertical: Option<LayoutSizingVertical>,
/// How this node blends with nodes behind it in the scene (see blend mode section for more details)
#[serde(rename = "blendMode")]
pub blend_mode: models::BlendMode,
/// Opacity of the node
#[serde(rename = "opacity", skip_serializing_if = "Option::is_none")]
pub opacity: Option<f64>,
/// An array of effects attached to this node (see effects section for more details)
#[serde(rename = "effects")]
pub effects: Vec<models::Effect>,
/// An array of export settings representing images to export from the node.
#[serde(rename = "exportSettings", skip_serializing_if = "Option::is_none")]
pub export_settings: Option<Vec<models::ExportSetting>>,
/// Text contained within a text box.
#[serde(rename = "characters")]
pub characters: String,
/// An array of stroke paints applied to the node.
#[serde(rename = "strokes", skip_serializing_if = "Option::is_none")]
pub strokes: Option<Vec<models::Paint>>,
/// The weight of strokes on the node.
#[serde(rename = "strokeWeight", skip_serializing_if = "Option::is_none")]
pub stroke_weight: Option<f64>,
/// Position of stroke relative to vector outline, as a string enum - `INSIDE`: stroke drawn inside the shape boundary - `OUTSIDE`: stroke drawn outside the shape boundary - `CENTER`: stroke drawn centered along the shape boundary
#[serde(rename = "strokeAlign", skip_serializing_if = "Option::is_none")]
pub stroke_align: Option<StrokeAlign>,
/// A string enum with value of \"MITER\", \"BEVEL\", or \"ROUND\", describing how corners in vector paths are rendered.
#[serde(rename = "strokeJoin", skip_serializing_if = "Option::is_none")]
pub stroke_join: Option<StrokeJoin>,
/// An array of floating point numbers describing the pattern of dash length and gap lengths that the vector stroke will use when drawn. For example a value of [1, 2] indicates that the stroke will be drawn with a dash of length 1 followed by a gap of length 2, repeated.
#[serde(rename = "strokeDashes", skip_serializing_if = "Option::is_none")]
pub stroke_dashes: Option<Vec<f64>>,
/// The starting point of the connector.
#[serde(rename = "connectorStart")]
pub connector_start: Box<models::ConnectorEndpoint>,
/// The ending point of the connector.
#[serde(rename = "connectorEnd")]
pub connector_end: Box<models::ConnectorEndpoint>,
/// A string enum describing the end cap of the start of the connector.
#[serde(rename = "connectorStartStrokeCap")]
pub connector_start_stroke_cap: ConnectorStartStrokeCap,
/// A string enum describing the end cap of the end of the connector.
#[serde(rename = "connectorEndStrokeCap")]
pub connector_end_stroke_cap: ConnectorEndStrokeCap,
/// Connector line type.
#[serde(rename = "connectorLineType")]
pub connector_line_type: models::ConnectorLineType,
/// Connector text background.
#[serde(rename = "textBackground", skip_serializing_if = "Option::is_none")]
pub text_background: Option<Box<models::ConnectorTextBackground>>,
}
impl ConnectorNode {
pub fn new(id: String, name: String, scroll_behavior: ScrollBehavior, blend_mode: models::BlendMode, effects: Vec<models::Effect>, characters: String, connector_start: models::ConnectorEndpoint, connector_end: models::ConnectorEndpoint, connector_start_stroke_cap: ConnectorStartStrokeCap, connector_end_stroke_cap: ConnectorEndStrokeCap, connector_line_type: models::ConnectorLineType) -> ConnectorNode {
ConnectorNode {
id,
name,
visible: None,
locked: None,
is_fixed: None,
scroll_behavior,
rotation: None,
component_property_references: None,
plugin_data: None,
shared_plugin_data: None,
bound_variables: None,
explicit_variable_modes: None,
preserve_ratio: None,
constraints: None,
relative_transform: None,
size: None,
layout_align: None,
layout_grow: None,
layout_positioning: None,
min_width: None,
max_width: None,
min_height: None,
max_height: None,
layout_sizing_horizontal: None,
layout_sizing_vertical: None,
blend_mode,
opacity: None,
effects,
export_settings: None,
characters,
strokes: None,
stroke_weight: None,
stroke_align: None,
stroke_join: None,
stroke_dashes: None,
connector_start: Box::new(connector_start),
connector_end: Box::new(connector_end),
connector_start_stroke_cap,
connector_end_stroke_cap,
connector_line_type,
text_background: None,
}
}
}
/// How layer should be treated when the frame is resized
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum ScrollBehavior {
#[serde(rename = "SCROLLS")]
Scrolls,
#[serde(rename = "FIXED")]
Fixed,
#[serde(rename = "STICKY_SCROLLS")]
StickyScrolls,
}
impl Default for ScrollBehavior {
fn default() -> ScrollBehavior {
Self::Scrolls
}
}
/// Determines if the layer should stretch along the parent's counter axis. This property is only provided for direct children of auto-layout frames. - `INHERIT` - `STRETCH` In previous versions of auto layout, determined how the layer is aligned inside an auto-layout frame. This property is only provided for direct children of auto-layout frames. - `MIN` - `CENTER` - `MAX` - `STRETCH` In horizontal auto-layout frames, \"MIN\" and \"MAX\" correspond to \"TOP\" and \"BOTTOM\". In vertical auto-layout frames, \"MIN\" and \"MAX\" correspond to \"LEFT\" and \"RIGHT\".
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum LayoutAlign {
#[serde(rename = "INHERIT")]
Inherit,
#[serde(rename = "STRETCH")]
Stretch,
#[serde(rename = "MIN")]
Min,
#[serde(rename = "CENTER")]
Center,
#[serde(rename = "MAX")]
Max,
}
impl Default for LayoutAlign {
fn default() -> LayoutAlign {
Self::Inherit
}
}
/// Determines whether a layer's size and position should be determined by auto-layout settings or manually adjustable.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum LayoutPositioning {
#[serde(rename = "AUTO")]
Auto,
#[serde(rename = "ABSOLUTE")]
Absolute,
}
impl Default for LayoutPositioning {
fn default() -> LayoutPositioning {
Self::Auto
}
}
/// The horizontal sizing setting on this auto-layout frame or frame child. - `FIXED` - `HUG`: only valid on auto-layout frames and text nodes - `FILL`: only valid on auto-layout frame children
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum LayoutSizingHorizontal {
#[serde(rename = "FIXED")]
Fixed,
#[serde(rename = "HUG")]
Hug,
#[serde(rename = "FILL")]
Fill,
}
impl Default for LayoutSizingHorizontal {
fn default() -> LayoutSizingHorizontal {
Self::Fixed
}
}
/// The vertical sizing setting on this auto-layout frame or frame child. - `FIXED` - `HUG`: only valid on auto-layout frames and text nodes - `FILL`: only valid on auto-layout frame children
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum LayoutSizingVertical {
#[serde(rename = "FIXED")]
Fixed,
#[serde(rename = "HUG")]
Hug,
#[serde(rename = "FILL")]
Fill,
}
impl Default for LayoutSizingVertical {
fn default() -> LayoutSizingVertical {
Self::Fixed
}
}
/// Position of stroke relative to vector outline, as a string enum - `INSIDE`: stroke drawn inside the shape boundary - `OUTSIDE`: stroke drawn outside the shape boundary - `CENTER`: stroke drawn centered along the shape boundary
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum StrokeAlign {
#[serde(rename = "INSIDE")]
Inside,
#[serde(rename = "OUTSIDE")]
Outside,
#[serde(rename = "CENTER")]
Center,
}
impl Default for StrokeAlign {
fn default() -> StrokeAlign {
Self::Inside
}
}
/// A string enum with value of \"MITER\", \"BEVEL\", or \"ROUND\", describing how corners in vector paths are rendered.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum StrokeJoin {
#[serde(rename = "MITER")]
Miter,
#[serde(rename = "BEVEL")]
Bevel,
#[serde(rename = "ROUND")]
Round,
}
impl Default for StrokeJoin {
fn default() -> StrokeJoin {
Self::Miter
}
}
/// A string enum describing the end cap of the start of the connector.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum ConnectorStartStrokeCap {
#[serde(rename = "NONE")]
None,
#[serde(rename = "LINE_ARROW")]
LineArrow,
#[serde(rename = "TRIANGLE_ARROW")]
TriangleArrow,
#[serde(rename = "DIAMOND_FILLED")]
DiamondFilled,
#[serde(rename = "CIRCLE_FILLED")]
CircleFilled,
#[serde(rename = "TRIANGLE_FILLED")]
TriangleFilled,
}
impl Default for ConnectorStartStrokeCap {
fn default() -> ConnectorStartStrokeCap {
Self::None
}
}
/// A string enum describing the end cap of the end of the connector.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum ConnectorEndStrokeCap {
#[serde(rename = "NONE")]
None,
#[serde(rename = "LINE_ARROW")]
LineArrow,
#[serde(rename = "TRIANGLE_ARROW")]
TriangleArrow,
#[serde(rename = "DIAMOND_FILLED")]
DiamondFilled,
#[serde(rename = "CIRCLE_FILLED")]
CircleFilled,
#[serde(rename = "TRIANGLE_FILLED")]
TriangleFilled,
}
impl Default for ConnectorEndStrokeCap {
fn default() -> ConnectorEndStrokeCap {
Self::None
}
}