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
pub use crate::type_id::TypeId;
use crate::borrow::Mutability;
use crate::storage::StorageId;
use alloc::borrow::Cow;
use alloc::vec::Vec;
#[derive(Debug, Clone)]
pub struct WorkloadInfo {
#[allow(missing_docs)]
pub name: Cow<'static, str>,
#[allow(missing_docs)]
pub batch_info: Vec<BatchInfo>,
}
#[derive(Debug, Clone)]
pub struct BatchInfo {
#[allow(missing_docs)]
pub systems: Vec<SystemInfo>,
}
#[derive(Clone)]
pub struct SystemInfo {
#[allow(missing_docs)]
pub name: &'static str,
#[allow(missing_docs)]
pub type_id: TypeId,
#[allow(missing_docs)]
pub borrow: Vec<TypeInfo>,
pub conflict: Option<Conflict>,
}
impl core::fmt::Debug for SystemInfo {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("StorageInfo")
.field("name", &self.name)
.field("borrow", &self.borrow)
.field("conflict", &self.conflict)
.finish()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Conflict {
Borrow {
#[allow(missing_docs)]
type_info: TypeInfo,
#[allow(missing_docs)]
other_system: SystemId,
#[allow(missing_docs)]
other_type_info: TypeInfo,
},
NotSendSync(TypeInfo),
OtherNotSendSync {
#[allow(missing_docs)]
system: SystemId,
#[allow(missing_docs)]
type_info: TypeInfo,
},
}
#[derive(Clone, Eq)]
pub struct SystemId {
#[allow(missing_docs)]
pub name: &'static str,
#[allow(missing_docs)]
pub type_id: TypeId,
}
impl PartialEq for SystemId {
fn eq(&self, other: &Self) -> bool {
self.type_id == other.type_id
}
}
impl core::fmt::Debug for SystemId {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.write_str(self.name)
}
}
#[derive(Clone, Eq)]
pub struct TypeInfo {
#[allow(missing_docs)]
pub name: &'static str,
#[allow(missing_docs)]
pub mutability: Mutability,
#[allow(missing_docs)]
pub storage_id: StorageId,
#[allow(missing_docs)]
pub is_send: bool,
#[allow(missing_docs)]
pub is_sync: bool,
}
impl PartialEq for TypeInfo {
fn eq(&self, rhs: &Self) -> bool {
self.storage_id == rhs.storage_id && self.mutability == rhs.mutability
}
}
impl PartialEq<(TypeId, Mutability)> for TypeInfo {
fn eq(&self, rhs: &(TypeId, Mutability)) -> bool {
self.storage_id == rhs.0 && self.mutability == rhs.1
}
}
impl core::fmt::Debug for TypeInfo {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut debug_struct = f.debug_struct("TypeInfo");
match (self.is_send, self.is_sync) {
(true, true) => debug_struct.field("name", &self.name),
(false, true) => {
debug_struct.field("name", &format_args!("shipyard::NonSend<{}>", self.name))
}
(true, false) => {
debug_struct.field("name", &format_args!("shipyard::NonSync<{}>", self.name))
}
(false, false) => debug_struct.field(
"name",
&format_args!("shipyard::NonSendSync<{}>", self.name),
),
}
.field("mutability", &self.mutability)
.finish()
}
}