Skip to content

Commit 8d2fbf7

Browse files
authored
Merge pull request #25 from pbs-data-solutions/seralizable
Implement Clone and Serialize for structs
2 parents 56cd6f7 + 6c7bdc9 commit 8d2fbf7

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed

src/native/common.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use chrono::{DateTime, Utc};
2-
use serde::Deserialize;
2+
use serde::{Deserialize, Serialize};
33

44
#[cfg(feature = "python")]
55
use pyo3::{prelude::*, types::PyDateTime};
@@ -13,7 +13,7 @@ use crate::native::deserializers::{
1313
use crate::native::deserializers::{to_py_datetime, to_py_datetime_option};
1414

1515
#[cfg(not(feature = "python"))]
16-
#[derive(Debug, Deserialize, PartialEq)]
16+
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
1717
#[serde(rename_all = "camelCase")]
1818
pub struct Value {
1919
pub by: String,
@@ -31,7 +31,7 @@ pub struct Value {
3131
}
3232

3333
#[cfg(feature = "python")]
34-
#[derive(Clone, Debug, Deserialize, PartialEq)]
34+
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
3535
#[serde(rename_all = "camelCase")]
3636
#[pyclass]
3737
pub struct Value {
@@ -79,7 +79,7 @@ impl Value {
7979
}
8080

8181
#[cfg(not(feature = "python"))]
82-
#[derive(Debug, Deserialize, PartialEq)]
82+
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
8383
#[serde(rename_all = "camelCase")]
8484
pub struct Reason {
8585
pub by: String,
@@ -98,7 +98,7 @@ pub struct Reason {
9898
}
9999

100100
#[cfg(feature = "python")]
101-
#[derive(Clone, Debug, Deserialize, PartialEq)]
101+
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
102102
#[serde(rename_all = "camelCase")]
103103
#[pyclass]
104104
pub struct Reason {
@@ -147,7 +147,7 @@ impl Reason {
147147
}
148148

149149
#[cfg(not(feature = "python"))]
150-
#[derive(Debug, Deserialize, PartialEq)]
150+
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
151151
#[serde(rename_all = "camelCase")]
152152
pub struct Entry {
153153
#[serde(alias = "id")]
@@ -157,7 +157,7 @@ pub struct Entry {
157157
}
158158

159159
#[cfg(feature = "python")]
160-
#[derive(Clone, Debug, Deserialize, PartialEq)]
160+
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
161161
#[serde(rename_all = "camelCase")]
162162
#[pyclass(get_all)]
163163
pub struct Entry {
@@ -168,7 +168,7 @@ pub struct Entry {
168168
}
169169

170170
#[cfg(not(feature = "python"))]
171-
#[derive(Debug, Deserialize, PartialEq)]
171+
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
172172
#[serde(rename_all = "camelCase")]
173173
pub struct Field {
174174
pub name: String,
@@ -190,7 +190,7 @@ pub struct Field {
190190
}
191191

192192
#[cfg(feature = "python")]
193-
#[derive(Clone, Debug, Deserialize, PartialEq)]
193+
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
194194
#[serde(rename_all = "camelCase")]
195195
#[pyclass]
196196
pub struct Field {
@@ -253,7 +253,7 @@ impl Field {
253253
}
254254

255255
#[cfg(not(feature = "python"))]
256-
#[derive(Debug, Deserialize, PartialEq)]
256+
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
257257
#[serde(rename_all = "camelCase")]
258258
pub struct Category {
259259
pub name: String,
@@ -268,7 +268,7 @@ pub struct Category {
268268
}
269269

270270
#[cfg(feature = "python")]
271-
#[derive(Clone, Debug, Deserialize, PartialEq)]
271+
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
272272
#[serde(rename_all = "camelCase")]
273273
#[pyclass(get_all)]
274274
pub struct Category {
@@ -284,7 +284,7 @@ pub struct Category {
284284
}
285285

286286
#[cfg(not(feature = "python"))]
287-
#[derive(Debug, Deserialize, PartialEq)]
287+
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
288288
#[serde(rename_all = "camelCase")]
289289
pub struct State {
290290
pub value: String,
@@ -299,7 +299,7 @@ pub struct State {
299299
}
300300

301301
#[cfg(feature = "python")]
302-
#[derive(Clone, Debug, Deserialize, PartialEq)]
302+
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
303303
#[serde(rename_all = "camelCase")]
304304
#[pyclass]
305305
pub struct State {
@@ -339,7 +339,7 @@ impl State {
339339
}
340340

341341
#[cfg(not(feature = "python"))]
342-
#[derive(Debug, Deserialize, PartialEq)]
342+
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
343343
#[serde(rename_all = "camelCase")]
344344
pub struct Form {
345345
pub name: String,
@@ -398,7 +398,7 @@ pub struct Form {
398398
}
399399

400400
#[cfg(feature = "python")]
401-
#[derive(Clone, Debug, Deserialize, PartialEq)]
401+
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
402402
#[serde(rename_all = "camelCase")]
403403
#[pyclass]
404404
pub struct Form {

src/native/site_native.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use chrono::{DateTime, Utc};
33
#[cfg(feature = "python")]
44
use pyo3::{prelude::*, types::PyDateTime};
55

6-
use serde::Deserialize;
6+
use serde::{Deserialize, Serialize};
77

88
pub use crate::native::{
99
common::{Category, Entry, Field, Form, Reason, State, Value},
@@ -17,7 +17,7 @@ pub use crate::native::{
1717
use crate::native::deserializers::to_py_datetime;
1818

1919
#[cfg(not(feature = "python"))]
20-
#[derive(Debug, Deserialize, PartialEq)]
20+
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
2121
#[serde(rename_all = "camelCase")]
2222
pub struct Site {
2323
pub name: String,
@@ -33,7 +33,7 @@ pub struct Site {
3333
}
3434

3535
#[cfg(feature = "python")]
36-
#[derive(Clone, Debug, Deserialize, PartialEq)]
36+
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
3737
#[serde(rename_all = "camelCase")]
3838
#[pyclass]
3939
pub struct Site {
@@ -95,7 +95,7 @@ impl Site {
9595

9696
#[cfg(not(feature = "python"))]
9797
/// Contains the information from the Prelude native site XML.
98-
#[derive(Debug, Deserialize, PartialEq)]
98+
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
9999
#[serde(rename_all = "camelCase")]
100100
pub struct SiteNative {
101101
#[serde(rename = "site", default)]
@@ -104,7 +104,7 @@ pub struct SiteNative {
104104

105105
#[cfg(feature = "python")]
106106
/// Contains the information from the Prelude native site XML.
107-
#[derive(Debug, Deserialize, PartialEq)]
107+
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
108108
#[serde(rename_all = "camelCase")]
109109
#[pyclass(get_all)]
110110
pub struct SiteNative {

src/native/subject_native.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use pyo3::{prelude::*, types::PyDateTime};
66
#[cfg(feature = "python")]
77
use crate::native::deserializers::to_py_datetime;
88

9-
use serde::Deserialize;
9+
use serde::{Deserialize, Serialize};
1010

1111
pub use crate::native::{
1212
common::{Category, Entry, Field, Form, Reason, State, Value},
@@ -17,7 +17,7 @@ pub use crate::native::{
1717
};
1818

1919
#[cfg(not(feature = "python"))]
20-
#[derive(Debug, Deserialize, PartialEq)]
20+
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
2121
#[serde(rename_all = "camelCase")]
2222
pub struct Patient {
2323
pub patient_id: String,
@@ -40,7 +40,7 @@ pub struct Patient {
4040
}
4141

4242
#[cfg(feature = "python")]
43-
#[derive(Clone, Debug, Deserialize, PartialEq)]
43+
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
4444
#[serde(rename_all = "camelCase")]
4545
#[pyclass]
4646
pub struct Patient {
@@ -114,7 +114,7 @@ impl Patient {
114114

115115
#[cfg(not(feature = "python"))]
116116
/// Contains the information from the Prelude native subject XML.
117-
#[derive(Debug, Deserialize, PartialEq)]
117+
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
118118
#[serde(rename_all = "camelCase")]
119119
pub struct SubjectNative {
120120
#[serde(rename = "patient", default)]
@@ -123,7 +123,7 @@ pub struct SubjectNative {
123123

124124
#[cfg(feature = "python")]
125125
/// Contains the information from the Prelude native subject XML.
126-
#[derive(Debug, Deserialize, PartialEq)]
126+
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
127127
#[serde(rename_all = "camelCase")]
128128
#[pyclass(get_all)]
129129
pub struct SubjectNative {

src/native/user_native.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use serde::Deserialize;
1+
use serde::{Deserialize, Serialize};
22

33
#[cfg(feature = "python")]
44
use pyo3::prelude::*;
@@ -12,7 +12,7 @@ pub use crate::native::{
1212
};
1313

1414
#[cfg(not(feature = "python"))]
15-
#[derive(Debug, Deserialize, PartialEq)]
15+
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
1616
#[serde(rename_all = "camelCase")]
1717
pub struct User {
1818
pub unique_id: String,
@@ -30,7 +30,7 @@ pub struct User {
3030
}
3131

3232
#[cfg(feature = "python")]
33-
#[derive(Clone, Debug, Deserialize, PartialEq)]
33+
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
3434
#[serde(rename_all = "camelCase")]
3535
#[pyclass(get_all)]
3636
pub struct User {
@@ -50,7 +50,7 @@ pub struct User {
5050

5151
#[cfg(not(feature = "python"))]
5252
/// Contains the information from the Prelude native user XML.
53-
#[derive(Debug, Deserialize, PartialEq)]
53+
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
5454
#[serde(rename_all = "camelCase")]
5555
pub struct UserNative {
5656
#[serde(rename = "user", default)]
@@ -59,7 +59,7 @@ pub struct UserNative {
5959

6060
#[cfg(feature = "python")]
6161
/// Contains the information from the Prelude native user XML.
62-
#[derive(Debug, Deserialize, PartialEq)]
62+
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
6363
#[serde(rename_all = "camelCase")]
6464
#[pyclass(get_all)]
6565
pub struct UserNative {

0 commit comments

Comments
 (0)