flow_gates/traits.rs
1use crate::error::Result;
2
3/// Trait for gate types that can calculate their geometric center
4pub trait GateCenter {
5 /// Calculate the center point in raw data coordinates
6 fn calculate_center(&self, x_param: &str, y_param: &str) -> Result<(f32, f32)>;
7}
8
9/// Trait for gate types that support point containment testing
10pub trait GateContainment {
11 /// Check if a point (in raw coordinates) is inside the gate
12 fn contains_point(&self, x: f32, y: f32, x_param: &str, y_param: &str) -> Result<bool>;
13}
14
15/// Trait for gate types that have a bounding box
16pub trait GateBounds {
17 /// Calculate the bounding box (min_x, min_y, max_x, max_y) in raw coordinates
18 fn bounding_box(&self, x_param: &str, y_param: &str) -> Result<(f32, f32, f32, f32)>;
19}
20
21/// Trait for gate types that can be validated
22pub trait GateValidation {
23 /// Check if the gate has valid geometry and coordinates
24 fn is_valid(&self, x_param: &str, y_param: &str) -> Result<bool>;
25}
26
27/// Common trait combining all gate behaviors
28pub trait GateGeometryOps: GateCenter + GateContainment + GateBounds + GateValidation {
29 /// Get a descriptive name for this gate type
30 fn gate_type_name(&self) -> &'static str;
31}