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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/// An edge ID
///
/// This is an integer referring to a row of an [``EdgeTable``](crate::EdgeTable).
///
/// The features for this type follow the same pattern as for [``NodeId``]
pub use crateEdgeId;
/// An individual ID
///
/// This is an integer referring to a row of an [``IndividualTable``](crate::IndividualTable).
///
/// The features for this type follow the same pattern as for [``NodeId``]
pub use crateIndividualId;
/// A mutation ID
///
/// This is an integer referring to a row of an [``MutationTable``](crate::MutationTable).
///
/// The features for this type follow the same pattern as for [``NodeId``]
pub use crateMutationId;
/// A migration ID
///
/// This is an integer referring to a row of an [``MigrationTable``](crate::MigrationTable).
///
/// The features for this type follow the same pattern as for [``NodeId``]
pub use crateMigrationId;
/// A node ID
///
/// This is an integer referring to a row of a [``NodeTable``](crate::NodeTable).
///
/// # Examples
///
/// These examples illustrate using this type as something "integer-like".
///
/// ```
/// use tskit::NodeId;
///
/// // The default value is null:
/// assert_eq!(tskit::NodeId::default(), tskit::NodeId::NULL);
///
/// let y: NodeId = NodeId::from(1);
/// assert_eq!(1, y);
/// assert_eq!(y, 1);
///
/// assert!(y < 2);
/// assert!(y <= 1);
/// assert!(2 > y);
/// assert!(1 + 1 >= y);
///
/// let z: NodeId = NodeId::from(1);
/// assert_eq!(y, z);
/// ```
///
/// It is also possible to write functions accepting both the `NodeId`
/// and `tsk_id_t`:
///
/// ```
/// use tskit::NodeId;
///
/// fn interesting<N: Into<NodeId>>(x: N) -> NodeId {
/// x.into()
/// }
///
/// let x = 1;
/// assert_eq!(interesting(x), x);
/// let x: NodeId = NodeId::from(0);
/// assert_eq!(interesting(x), x);
/// ```
///
/// The types also implement `Display`:
///
/// ```
/// use tskit::NodeId;
///
/// let n = NodeId::from(11);
/// assert_eq!(format!("{}", n), "11".to_string());
/// // Debug output contains type info
/// assert_eq!(format!("{:?}", n), "NodeId(11)".to_string());
/// let n = NodeId::from(NodeId::NULL);
/// assert_eq!(format!("{}", n), "NULL");
/// assert_eq!(format!("{:?}", n), "NodeId(-1)");
/// ```
///
pub use crateNodeId;
/// A population ID
///
/// This is an integer referring to a row of an [``PopulationTable``](crate::PopulationTable).
///
/// The features for this type follow the same pattern as for [``NodeId``]
pub use cratePopulationId;
/// A provenance ID
///
/// This is an integer referring to a row of a [``crate::provenance::ProvenanceTable``].
///
/// The features for this type follow the same pattern as for [``NodeId``]
pub use crateProvenanceId;
/// A site ID
///
/// This is an integer referring to a row of an [``SiteTable``](crate::SiteTable).
///
/// The features for this type follow the same pattern as for [``NodeId``]
pub use crateSiteId;
/// Wraps `tsk_size_t`
///
/// This type plays the role of C's `size_t` in the `tskit` C library.
///
/// # Examples
///
/// ```
/// # #[cfg(feature = "bindings")]
/// # {
/// let s = tskit::SizeType::from(1);
/// let mut t: tskit::bindings::tsk_size_t = s.into();
/// assert!(t == s);
/// assert!(t == 1);
/// let u = tskit::SizeType::from(s);
/// assert!(u == s);
/// t += 1;
/// assert!(t > s);
/// assert!(s < t);
/// # }
/// ```
///
/// #[repr(transparent)]
pub use crateSizeType;
/// A newtype for the concept of "genomic position".
/// A `Position` can represent either a locus or a
/// distance between loci.
///
/// Wraps [`f64`].
///
/// For examples, see [`Time`].
///
/// This type can be multiplied and divided by [`Time`].
pub use cratePosition;
/// A newtype for the concept of location.
/// A `Location` may represent a location or the
/// output of arithmetic involving locations.
///
/// Wraps [`f64`].
///
/// For examples, see [`Time`].
///
pub use crateLocation;
/// A newtype for the concept of time.
/// A `Time` value can represent either a point in time
/// or the output of arithmetic involving time.
///
/// Wraps [`f64`].
///
/// # Examples
///
/// ```
/// let t0 = tskit::Time::from(2.0);
/// let t1 = tskit::Time::from(10.0);
///
/// let mut sum = t0 + t1;
///
/// match sum.partial_cmp(&12.0) {
/// Some(std::cmp::Ordering::Equal) => (),
/// _ => assert!(false),
/// };
///
/// sum /= tskit::Time::from(2.0);
///
/// match sum.partial_cmp(&6.0) {
/// Some(std::cmp::Ordering::Equal) => (),
/// _ => assert!(false),
/// };
/// ```
///
/// # Notes
///
/// The current implementation of [`PartialOrd`] is based on
/// the underlying implementation for [`f64`].
///
/// A `Time` can be multiplied and divided by a [`Position`]
///
pub use crateTime;