pddl_parser/domain/
typedef.rs

1use serde::{Deserialize, Serialize};
2
3/// A type definition.
4#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
5pub struct TypeDef {
6    /// The name of the type.
7    pub name: String,
8    /// The parent type. If not specified, the parent type is `object`.
9    pub parent: Option<String>,
10}
11
12impl TypeDef {
13    /// Convert the type definition to PDDL.
14    pub fn to_pddl(&self) -> String {
15        self.parent
16            .as_ref()
17            .map_or_else(|| self.name.clone(), |parent| format!("{} - {}", self.name, parent))
18    }
19}