cellular_raza_core/backend/cpu_os_threads/
trait_bounds.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
use cellular_raza_concepts::*;

use core::fmt::Debug;
use core::ops::{Add, AddAssign, Mul, Sub, SubAssign};
use num::Zero;

// TODO use trait alias when available
/* pub trait Position = Sized
+ Add<Self, Output = Self>
+ AddAssign
+ Sub<Output = Self>
+ SubAssign
+ Clone
+ Debug
+ Send
+ Sync
+ Mul<f64, Output = Self>;*/
/// Represents the current position of a cell-agent.
pub trait PositionBound:
    Sized
    + Add<Self, Output = Self>
    + AddAssign
    + Sub<Output = Self>
    + SubAssign
    + Clone
    + Debug
    + Send
    + Sync
    + Mul<f64, Output = Self>
{
}
impl<T> PositionBound for T where
    T: Sized
        + Add<Self, Output = Self>
        + AddAssign
        + Sub<Output = Self>
        + SubAssign
        + Clone
        + Debug
        + Send
        + Sync
        + Mul<f64, Output = Self>
{
}

// TODO use trait alias when available
/* pub trait Force = Sized
+ Add<Self, Output = Self>
+ AddAssign
+ Sub<Output = Self>
+ SubAssign
+ Clone
+ Debug
+ Zero
+ Send
+ Sync
+ Mul<f64, Output = Self>;*/
/// Represents a force which can act between two cells.
pub trait ForceBound:
    Sized
    + Add<Self, Output = Self>
    + AddAssign
    + Sub<Output = Self>
    + SubAssign
    + Clone
    + Debug
    + Zero
    + Send
    + Sync
    + Mul<f64, Output = Self>
{
}
impl<T> ForceBound for T where
    T: Sized
        + Add<Self, Output = Self>
        + AddAssign
        + Sub<Output = Self>
        + SubAssign
        + Clone
        + Debug
        + Zero
        + Send
        + Sync
        + Mul<f64, Output = Self>
{
}

// TODO use trait alias when available
/* pub trait Velocity = Sized
+ Add<Self, Output = Self>
+ AddAssign
+ Sub<Output = Self>
+ SubAssign
+ Clone
+ Debug
+ Zero
+ Send
+ Sync
+ Mul<f64, Output = Self>;*/
/// Represents the velocity of a cell.
pub trait VelocityBound:
    Sized
    + Add<Self, Output = Self>
    + AddAssign
    + Sub<Output = Self>
    + SubAssign
    + Clone
    + Debug
    + Zero
    + Send
    + Sync
    + Mul<f64, Output = Self>
{
}
impl<T> VelocityBound for T where
    T: Sized
        + Add<Self, Output = Self>
        + AddAssign
        + Sub<Output = Self>
        + SubAssign
        + Clone
        + Debug
        + Zero
        + Send
        + Sync
        + Mul<f64, Output = Self>
{
}

/// Encapsulates all concepts that can be specified for a [Agent]
///
/// We hope to be deprecating this trait in the future and only rely on individual traits instead.
/// While this trait could be manually implemented, it is often not necessary (see [cellular_raza-building-blocks](https://docs.rs/cellular_raza-building-blocks))
pub trait Agent<Pos: PositionBound, Vel: VelocityBound, For: ForceBound, Inf, Float = f64>:
    Cycle<Self, Float>
    + Interaction<Pos, Vel, For, Inf>
    + Mechanics<Pos, Vel, For, Float>
    + Position<Pos>
    + Velocity<Vel>
    + Sized
    + Send
    + Sync
    + Clone
    + serde::Serialize
    + for<'a> serde::Deserialize<'a>
{
}
impl<Pos, Vel, For, Inf, Float, A> Agent<Pos, Vel, For, Inf, Float> for A
where
    Pos: PositionBound,
    For: ForceBound,
    Vel: VelocityBound,
    A: Cycle<Self, Float>
        + Interaction<Pos, Vel, For, Inf>
        + Mechanics<Pos, Vel, For, Float>
        + Position<Pos>
        + Velocity<Vel>
        + Sized
        + Send
        + Sync
        + Clone
        + serde::Serialize
        + for<'a> serde::Deserialize<'a>,
{
}

// TODO Define trait aliases for Position and Force

// TODO use trait alias when available
// pub trait InteractionInformation = Send + Sync + Clone + core::fmt::Debug;
/// Trait implementations needed for the information generic parameter of [Interaction].
pub trait InteractionInformation: Send + Sync + Clone + core::fmt::Debug {}
impl<T> InteractionInformation for T where T: Send + Sync + Clone + core::fmt::Debug {}