Skip to main content

modelio/
protocols.rs

1use crate::object::Object;
2use crate::Result;
3
4/// Mirrors the corresponding Model I/O named protocol counterpart.
5pub trait Named {
6    fn name(&self) -> Option<String>;
7    fn set_name(&self, name: &str) -> Result<()>;
8}
9
10/// Mirrors the corresponding Model I/O component protocol counterpart.
11pub trait Component {}
12
13/// Mirrors the corresponding Model I/O object container component: component protocol counterpart.
14pub trait ObjectContainerComponent: Component {
15    fn count(&self) -> usize;
16    fn object_at(&self, index: usize) -> Option<Object>;
17
18    fn objects(&self) -> Vec<Object> {
19        (0..self.count())
20            .filter_map(|index| self.object_at(index))
21            .collect()
22    }
23
24    fn add_object(&self, object: &Object);
25    fn remove_object(&self, object: &Object);
26}
27
28/// Mirrors the corresponding Model I/O joint animation protocol counterpart.
29pub trait JointAnimation {}