File tree Expand file tree Collapse file tree 3 files changed +36
-3
lines changed
crates/vertigo/src/driver_module/js_value Expand file tree Collapse file tree 3 files changed +36
-3
lines changed Original file line number Diff line number Diff line change 52
52
- uses : actions/checkout@v2
53
53
- uses : actions-rs/toolchain@v1
54
54
with :
55
- toolchain : nightly-2024-02-28
55
+ toolchain : nightly-2024-07-01
56
56
target : wasm32-unknown-unknown
57
57
components : clippy
58
58
override : true
74
74
- uses : actions/checkout@v2
75
75
- uses : actions-rs/toolchain@v1
76
76
with :
77
- toolchain : nightly-2024-02-28
77
+ toolchain : nightly-2024-07-01
78
78
target : wasm32-unknown-unknown
79
79
components : clippy
80
80
override : true
85
85
- name : vertigo-cli
86
86
run : |
87
87
cargo build --release -p vertigo-cli
88
- rustup default nightly-2024-02-28
88
+ rustup default nightly-2024-07-01
89
89
mkdir ../vertigo-cli-test
90
90
mv target/release/vertigo ../vertigo-cli-test
91
91
cd ../vertigo-cli-test
Original file line number Diff line number Diff line change 8
8
* ` Reactive ` trait that allows generic components to be more flexible with props
9
9
* ` BTreeMap ` and ` chrono::DateTime<Utc> ` support in ` AutoJsJson `
10
10
* ` #[js_json(default = "None")] ` attribute to ` AutoJsJson `
11
+ * ` JsJson ` implementation for unit type ` () `
11
12
* All http methods in ` FetchMethod `
12
13
* ` history_replace ` method in ` Driver `
13
14
* vertigo-cli: ` add-watch-path ` to ` watch ` command
Original file line number Diff line number Diff line change @@ -171,6 +171,25 @@ impl JsJsonDeserialize for bool {
171
171
}
172
172
}
173
173
174
+ impl JsJsonSerialize for ( ) {
175
+ fn to_json ( self ) -> JsJson {
176
+ JsJson :: Object ( HashMap :: default ( ) )
177
+ }
178
+ }
179
+
180
+ impl JsJsonDeserialize for ( ) {
181
+ fn from_json ( context : JsJsonContext , json : JsJson ) -> Result < Self , JsJsonContext > {
182
+ let map = json. get_hashmap ( & context) ?;
183
+
184
+ if !map. is_empty ( ) {
185
+ let message = "Empty {} expected, inner content received" . to_string ( ) ;
186
+ return Err ( context. add ( message) )
187
+ }
188
+
189
+ Ok ( ( ) )
190
+ }
191
+ }
192
+
174
193
impl JsJsonSerialize for & str {
175
194
fn to_json ( self ) -> JsJson {
176
195
JsJson :: String ( self . into ( ) )
@@ -384,4 +403,17 @@ mod tests {
384
403
385
404
assert_eq ! ( ccc, eee) ;
386
405
}
406
+
407
+ #[ test]
408
+ fn test_unit ( ) {
409
+ let unit = JsJson :: Object ( HashMap :: default ( ) ) ;
410
+
411
+ let Ok ( ( ) ) = from_json :: < ( ) > ( unit. clone ( ) ) else {
412
+ unreachable ! ( ) ;
413
+ } ;
414
+
415
+ let unit2 = to_json ( ( ) ) ;
416
+
417
+ assert_eq ! ( unit2, unit)
418
+ }
387
419
}
You can’t perform that action at this time.
0 commit comments