1
+ //! The configuration model
2
+ //!
3
+ //! This is what the user provides, and which gets converted into the runtime model.
4
+
1
5
use crate :: config:: { RtcBuild , RtcClean , RtcServe , RtcWatch } ;
2
6
use anyhow:: { Context , Result } ;
3
- use axum:: http:: Uri ;
4
- use serde:: { Deserialize , Deserializer } ;
5
- use std:: fmt:: { Display , Formatter } ;
7
+ use serde:: Deserialize ;
6
8
use std:: path:: PathBuf ;
7
- use std:: str:: FromStr ;
8
9
use std:: sync:: Arc ;
9
10
10
- #[ cfg( test) ]
11
- mod test;
12
-
13
11
mod build;
14
12
mod clean;
15
13
mod core;
@@ -30,17 +28,8 @@ pub use tools::*;
30
28
pub use types:: * ;
31
29
pub use watch:: * ;
32
30
33
- /// Deserialize a Uri from a string.
34
- fn deserialize_uri < ' de , D , T > ( data : D ) -> std:: result:: Result < T , D :: Error >
35
- where
36
- D : Deserializer < ' de > ,
37
- T : From < Uri > ,
38
- {
39
- let val = String :: deserialize ( data) ?;
40
- Uri :: from_str ( val. as_str ( ) )
41
- . map ( Into :: into)
42
- . map_err ( |err| serde:: de:: Error :: custom ( err. to_string ( ) ) )
43
- }
31
+ #[ cfg( test) ]
32
+ mod test;
44
33
45
34
/// A model of all potential configuration options for the Trunk CLI system.
46
35
#[ derive( Clone , Debug , Default , Deserialize ) ]
@@ -461,36 +450,3 @@ impl ConfigOpts {
461
450
greater
462
451
}
463
452
}
464
-
465
- /// Cross origin setting
466
- #[ derive( Copy , Clone , PartialEq , Eq , Debug , Default ) ]
467
- pub enum CrossOrigin {
468
- #[ default]
469
- Anonymous ,
470
- UseCredentials ,
471
- }
472
-
473
- impl CrossOrigin {
474
- pub fn from_str ( s : & str ) -> Result < Self , CrossOriginParseError > {
475
- Ok ( match s {
476
- "" | "anonymous" => CrossOrigin :: Anonymous ,
477
- "use-credentials" => CrossOrigin :: UseCredentials ,
478
- _ => return Err ( CrossOriginParseError :: InvalidValue ) ,
479
- } )
480
- }
481
- }
482
-
483
- impl Display for CrossOrigin {
484
- fn fmt ( & self , f : & mut Formatter < ' _ > ) -> std:: fmt:: Result {
485
- match self {
486
- Self :: Anonymous => write ! ( f, "anonymous" ) ,
487
- Self :: UseCredentials => write ! ( f, "use-credentials" ) ,
488
- }
489
- }
490
- }
491
-
492
- #[ derive( Debug , thiserror:: Error ) ]
493
- pub enum CrossOriginParseError {
494
- #[ error( "invalid value" ) ]
495
- InvalidValue ,
496
- }
0 commit comments