pub struct Entity {
pub name: String,
pub entities: Vec<EntityType>,
pub description: Option<Description>,
}
Expand description
The representation of an Entity as a possbile generic node on the abstract syntax tree. An Entity has to be kind of a EntityType.
Fields§
§name: String
§entities: Vec<EntityType>
§description: Option<Description>
Implementations§
Source§impl Entity
impl Entity
Sourcepub fn new<S: Into<String>>(name: S) -> Self
pub fn new<S: Into<String>>(name: S) -> Self
Creates a new Entity instance.
§Example
use thinlinelib::entity::Entity;
let class = Entity::new("testClass");
assert_eq!(class.name, "testClass");
assert!(class.entities.is_empty());
Sourcepub fn add_entity<T>(&mut self, entity: EntityType) -> Option<&mut T>where
T: EntityConversion,
pub fn add_entity<T>(&mut self, entity: EntityType) -> Option<&mut T>where
T: EntityConversion,
Adds an Entity to the Entity instance.
§Example
use thinlinelib::entity::{Entity, EntityType};
let mut entity = Entity::new("outer_entity");
let entity_type = EntityType::Entity(Entity::new("inner_entity"));
entity.add_entity::<Entity>(entity_type);
assert_eq!(entity.entities.len(), 1);
Sourcepub fn set_description(&mut self, description: &str)
pub fn set_description(&mut self, description: &str)
Sets the description for the Entity.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Entity
impl<'de> Deserialize<'de> for Entity
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl EntityConversion for Entity
impl EntityConversion for Entity
impl StructuralPartialEq for Entity
Auto Trait Implementations§
impl Freeze for Entity
impl RefUnwindSafe for Entity
impl Send for Entity
impl Sync for Entity
impl Unpin for Entity
impl UnwindSafe for Entity
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more