File tree 6 files changed +63
-0
lines changed
6 files changed +63
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,11 @@ exclude = [".github"]
19
19
name = " simple"
20
20
required-features = [" toml" ]
21
21
22
+ [[test ]]
23
+ name = " indirect-serde"
24
+ path = " tests/indirect-serde/run.rs"
25
+ harness = false
26
+
22
27
23
28
[features ]
24
29
default = [" toml" , " yaml" , " json5" ]
Original file line number Diff line number Diff line change
1
+ target /
Original file line number Diff line number Diff line change
1
+ [package ]
2
+ name = " indirect-serde"
3
+ version = " 0.0.0"
4
+ edition = " 2021"
5
+
6
+ [dependencies ]
7
+ confique = { path = " ../.." , default-features = false }
Original file line number Diff line number Diff line change
1
+ This is just a compile test to make sure ` confique ` 's derives also work when the using crate does not have ` serde ` in its direct dependencies.
2
+ Having this test as separate folder with a ` run.rs ` calling ` cargo ` was the easiest way I found to do that.
3
+ That way, this is also executed as part of ` cargo test ` .
Original file line number Diff line number Diff line change
1
+ use std:: process:: Command ;
2
+
3
+ fn main ( ) {
4
+ let res = Command :: new ( "cargo" )
5
+ . args ( [ "check" ] )
6
+ . current_dir ( "tests/indirect-serde" )
7
+ . status ( ) ;
8
+
9
+ assert ! ( res. is_ok_and( |exitcode| exitcode. success( ) ) ) ;
10
+ }
Original file line number Diff line number Diff line change
1
+ #![ allow( dead_code) ]
2
+
3
+ use confique:: Config ;
4
+
5
+ #[ derive( Config ) ]
6
+ struct Conf {
7
+ #[ config( deserialize_with = my_deserialize_fn) ]
8
+ username : String ,
9
+
10
+ normal : u32 ,
11
+
12
+ opt : Option < String > ,
13
+
14
+ #[ config( nested) ]
15
+ nested : Nested ,
16
+ }
17
+
18
+ #[ derive( Config ) ]
19
+ struct Nested {
20
+ #[ config( env = "APP_PORT" ) ]
21
+ port : u16 ,
22
+
23
+ #[ config( default = "127.0.0.1" ) ]
24
+ bind : std:: net:: IpAddr ,
25
+
26
+ #[ config( default = [ "x-user" , "x-password" ] ) ]
27
+ headers : Vec < String > ,
28
+ }
29
+
30
+ fn my_deserialize_fn < ' de , D > ( _: D ) -> Result < String , D :: Error >
31
+ where
32
+ D : confique:: serde:: Deserializer < ' de > ,
33
+ {
34
+ todo ! ( )
35
+ }
36
+
37
+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments