@@ -5,6 +5,9 @@ extern crate confy;
55#[ macro_use]
66extern crate serde_derive;
77
8+ use std:: io:: Read ;
9+ use confy:: ConfyError ;
10+
811#[ derive( Debug , Serialize , Deserialize ) ]
912struct ConfyConfig {
1013 name : String ,
@@ -28,5 +31,27 @@ fn main() -> Result<(), confy::ConfyError> {
2831 println ! ( "The configuration file path is: {:#?}" , file) ;
2932 println ! ( "The configuration is:" ) ;
3033 println ! ( "{:#?}" , cfg) ;
34+ println ! ( "The wrote toml file content is:" ) ;
35+ let mut content = String :: new ( ) ;
36+ std:: fs:: File :: open ( & file)
37+ . expect ( "Failed to read toml configuration file." )
38+ . read_to_string ( & mut content) ;
39+ println ! ( "{}" , content) ;
40+ let cfg = ConfyConfig {
41+ name : "Test" . to_string ( ) ,
42+ ..cfg
43+ } ;
44+ confy:: store ( "confy_simple_app" , None , & cfg) ?;
45+ println ! ( "The updated toml file content is:" ) ;
46+ let mut content = String :: new ( ) ;
47+ std:: fs:: File :: open ( & file)
48+ . expect ( "Failed to read toml configuration file." )
49+ . read_to_string ( & mut content) ;
50+ println ! ( "{}" , content) ;
51+ let cfg = ConfyConfig {
52+ name : "Test" . to_string ( ) ,
53+ ..cfg
54+ } ;
55+ std:: fs:: remove_dir_all ( file. parent ( ) . unwrap ( ) ) ;
3156 Ok ( ( ) )
3257}
0 commit comments