rive_rs/bones/
skinnable.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Copyright 2021 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

use std::fmt;

use crate::bones::Skin;
use crate::core::{Object, ObjectRef};
use crate::shapes::PointsPath;

pub fn try_from(core: Object) -> Option<Object> {
    core.try_cast::<PointsPath>().map(|object| object.into())
}

pub fn as_ref(object_ref: ObjectRef<'_>) -> impl Skinnable + '_ {
    object_ref.cast::<PointsPath>()
}

pub trait Skinnable: fmt::Debug {
    fn skin(&self) -> Option<Object<Skin>>;
    fn set_skin(&self, skin: Object<Skin>);
    fn mark_skin_dirty(&self);
}