Skip to main content

flash_lso/types/
class_definition.rs

1use super::Attribute;
2use enumset::EnumSet;
3
4/// A class definition (trait) used in AMF3
5#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
6#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
7pub struct ClassDefinition {
8    /// The name of the class definition
9    pub name: String,
10
11    /// The attributes on this trait
12    pub attributes: EnumSet<Attribute>,
13
14    /// The name of the static properties defined in this definition
15    pub static_properties: Vec<String>,
16}
17
18impl Default for ClassDefinition {
19    fn default() -> Self {
20        Self {
21            name: "Object".to_string(),
22            attributes: EnumSet::empty(),
23            static_properties: Vec::new(),
24        }
25    }
26}
27
28impl ClassDefinition {
29    /// Creates a new ClassDefinition with the given name, and no attributes or properties
30    pub fn default_with_name(name: String) -> Self {
31        Self {
32            name,
33            attributes: EnumSet::empty(),
34            static_properties: Vec::new(),
35        }
36    }
37}