#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum BooleanOpType {
Union,
Intersection,
Difference,
}
impl BooleanOpType {
pub fn parse(s: &str) -> Option<Self> {
match s {
"union" => Some(BooleanOpType::Union),
"intersection" => Some(BooleanOpType::Intersection),
"difference" => Some(BooleanOpType::Difference),
_ => None,
}
}
pub fn as_str(&self) -> &'static str {
match self {
BooleanOpType::Union => "union",
BooleanOpType::Intersection => "intersection",
BooleanOpType::Difference => "difference",
}
}
}
#[derive(Debug, Clone)]
pub struct BooleanRef {
pub objectid: usize,
pub path: Option<String>,
}
impl BooleanRef {
pub fn new(objectid: usize) -> Self {
Self {
objectid,
path: None,
}
}
}
#[derive(Debug, Clone)]
pub struct BooleanShape {
pub objectid: usize,
pub operation: BooleanOpType,
pub path: Option<String>,
pub operands: Vec<BooleanRef>,
}
impl BooleanShape {
pub fn new(objectid: usize, operation: BooleanOpType) -> Self {
Self {
objectid,
operation,
path: None,
operands: Vec::new(),
}
}
}