cellular_raza_core/backend/cpu_os_threads/
trait_bounds.rs1use cellular_raza_concepts::*;
2
3use core::fmt::Debug;
4use core::ops::{Add, AddAssign, Mul, Sub, SubAssign};
5use num::Zero;
6
7pub trait PositionBound:
20 Sized
21 + Add<Self, Output = Self>
22 + AddAssign
23 + Sub<Output = Self>
24 + SubAssign
25 + Clone
26 + Debug
27 + Send
28 + Sync
29 + Mul<f64, Output = Self>
30{
31}
32impl<T> PositionBound for T where
33 T: Sized
34 + Add<Self, Output = Self>
35 + AddAssign
36 + Sub<Output = Self>
37 + SubAssign
38 + Clone
39 + Debug
40 + Send
41 + Sync
42 + Mul<f64, Output = Self>
43{
44}
45
46pub trait ForceBound:
60 Sized
61 + Add<Self, Output = Self>
62 + AddAssign
63 + Sub<Output = Self>
64 + SubAssign
65 + Clone
66 + Debug
67 + Zero
68 + Send
69 + Sync
70 + Mul<f64, Output = Self>
71{
72}
73impl<T> ForceBound for T where
74 T: Sized
75 + Add<Self, Output = Self>
76 + AddAssign
77 + Sub<Output = Self>
78 + SubAssign
79 + Clone
80 + Debug
81 + Zero
82 + Send
83 + Sync
84 + Mul<f64, Output = Self>
85{
86}
87
88pub trait VelocityBound:
102 Sized
103 + Add<Self, Output = Self>
104 + AddAssign
105 + Sub<Output = Self>
106 + SubAssign
107 + Clone
108 + Debug
109 + Zero
110 + Send
111 + Sync
112 + Mul<f64, Output = Self>
113{
114}
115impl<T> VelocityBound for T where
116 T: Sized
117 + Add<Self, Output = Self>
118 + AddAssign
119 + Sub<Output = Self>
120 + SubAssign
121 + Clone
122 + Debug
123 + Zero
124 + Send
125 + Sync
126 + Mul<f64, Output = Self>
127{
128}
129
130pub trait Agent<Pos: PositionBound, Vel: VelocityBound, For: ForceBound, Inf, Float = f64>:
135 Cycle<Self, Float>
136 + Interaction<Pos, Vel, For, Inf>
137 + Mechanics<Pos, Vel, For, Float>
138 + Position<Pos>
139 + Velocity<Vel>
140 + Sized
141 + Send
142 + Sync
143 + Clone
144 + serde::Serialize
145 + for<'a> serde::Deserialize<'a>
146{
147}
148impl<Pos, Vel, For, Inf, Float, A> Agent<Pos, Vel, For, Inf, Float> for A
149where
150 Pos: PositionBound,
151 For: ForceBound,
152 Vel: VelocityBound,
153 A: Cycle<Self, Float>
154 + Interaction<Pos, Vel, For, Inf>
155 + Mechanics<Pos, Vel, For, Float>
156 + Position<Pos>
157 + Velocity<Vel>
158 + Sized
159 + Send
160 + Sync
161 + Clone
162 + serde::Serialize
163 + for<'a> serde::Deserialize<'a>,
164{
165}
166
167pub trait InteractionInf: Send + Sync + Clone + core::fmt::Debug {}
173impl<T> InteractionInf for T where T: Send + Sync + Clone + core::fmt::Debug {}