rive_rs/importers/
artboard_importer.rs

1// Copyright 2021 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5use crate::animation::{LinearAnimation, StateMachine};
6use crate::artboard::Artboard;
7use crate::core::Object;
8use crate::importers::ImportStackObject;
9use crate::status_code::StatusCode;
10
11#[derive(Debug)]
12pub struct ArtboardImporter {
13    artboard: Object<Artboard>,
14}
15
16impl ArtboardImporter {
17    pub fn new(artboard: Object<Artboard>) -> Self {
18        Self { artboard }
19    }
20
21    pub fn push_object(&self, object: Object) {
22        self.artboard.as_ref().push_object(object);
23    }
24
25    pub fn push_animation(&self, animation: Object<LinearAnimation>) {
26        self.artboard.as_ref().push_animation(animation);
27    }
28
29    pub fn _push_state_machine(&self, state_machine: Object<StateMachine>) {
30        self.artboard.as_ref().push_state_machine(state_machine);
31    }
32}
33
34impl ImportStackObject for ArtboardImporter {
35    fn resolve(&self) -> StatusCode {
36        self.artboard.as_ref().initialize()
37    }
38}