diff --git a/pages/all.html b/pages/all.html index 3133ee0..84b6813 100644 --- a/pages/all.html +++ b/pages/all.html @@ -2,5 +2,5 @@

List of all items[] -

Structs

Functions

Constants

+

Structs

Functions

Constants

\ No newline at end of file diff --git a/pages/constant.GIT_COMMIT_HASH.html b/pages/constant.GIT_COMMIT_HASH.html index b3297e9..32d1ad0 100644 --- a/pages/constant.GIT_COMMIT_HASH.html +++ b/pages/constant.GIT_COMMIT_HASH.html @@ -1,4 +1,4 @@ GIT_COMMIT_HASH in pages - Rust

Constant pages::GIT_COMMIT_HASH[][src]

pub const GIT_COMMIT_HASH: &str = "e12c8989fb8205650404ed128e0afbf2773d1f96";
+

Constant pages::GIT_COMMIT_HASH[][src]

pub const GIT_COMMIT_HASH: &str = "c6f9cb7ac1d7e9a4b945cae402686383608bc71d";
\ No newline at end of file diff --git a/pages/settings/fn.check_url.html b/pages/settings/fn.check_url.html deleted file mode 100644 index ee3580c..0000000 --- a/pages/settings/fn.check_url.html +++ /dev/null @@ -1,4 +0,0 @@ -check_url in pages::settings - Rust -

Function pages::settings::check_url[][src]

fn check_url(s: &Config)
- \ No newline at end of file diff --git a/pages/settings/index.html b/pages/settings/index.html index 4b60d78..3bb8500 100644 --- a/pages/settings/index.html +++ b/pages/settings/index.html @@ -1,6 +1,5 @@ pages::settings - Rust

Module pages::settings[][src]

Structs

-

Functions

-
+

Module settings

Module pages::settings[][src]

Structs

+
\ No newline at end of file diff --git a/pages/settings/sidebar-items.js b/pages/settings/sidebar-items.js index 3114444..d855c5e 100644 --- a/pages/settings/sidebar-items.js +++ b/pages/settings/sidebar-items.js @@ -1 +1 @@ -initSidebarItems({"fn":[["check_url",""]],"struct":[["Server",""],["Settings",""]]}); \ No newline at end of file +initSidebarItems({"struct":[["Server",""],["Settings",""]]}); \ No newline at end of file diff --git a/pages/settings/struct.Settings.html b/pages/settings/struct.Settings.html index 4e3b750..e7fd6b4 100644 --- a/pages/settings/struct.Settings.html +++ b/pages/settings/struct.Settings.html @@ -1,10 +1,10 @@ Settings in pages::settings - Rust

Struct pages::settings::Settings[][src]

pub struct Settings {
+        

Struct Settings

Struct pages::settings::Settings[][src]

pub struct Settings {
     pub server: Server,
     pub source_code: String,
     pub pages: Vec<Page>,
-}

Fields

server: Serversource_code: Stringpages: Vec<Page>

Implementations

Trait Implementations

Returns a copy of the value. Read more

+}

Fields

server: Serversource_code: Stringpages: Vec<Page>

Implementations

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

diff --git a/pages/struct.SETTINGS.html b/pages/struct.SETTINGS.html index 829d2f1..fde0afd 100644 --- a/pages/struct.SETTINGS.html +++ b/pages/struct.SETTINGS.html @@ -1,8 +1,8 @@ SETTINGS in pages - Rust

Struct pages::SETTINGS[][src]

pub struct SETTINGS {
+        

Struct SETTINGS

Struct pages::SETTINGS[][src]

pub struct SETTINGS {
     pub(crate) __private_field: (),
-}

Fields

__private_field: ()

Trait Implementations

The resulting type after dereferencing.

+}

Fields

__private_field: ()

Methods from Deref<Target = Settings>

Trait Implementations

The resulting type after dereferencing.

Dereferences the value.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

diff --git a/pages/struct.Settings.html b/pages/struct.Settings.html index 7430404..a444aed 100644 --- a/pages/struct.Settings.html +++ b/pages/struct.Settings.html @@ -1,10 +1,10 @@ Settings in pages - Rust

Struct pages::Settings[][src]

pub struct Settings {
+        

Struct Settings

Struct pages::Settings[][src]

pub struct Settings {
     pub server: Server,
     pub source_code: String,
     pub pages: Vec<Page>,
-}

Fields

server: Serversource_code: Stringpages: Vec<Page>

Implementations

Trait Implementations

Returns a copy of the value. Read more

+}

Fields

server: Serversource_code: Stringpages: Vec<Page>

Implementations

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

diff --git a/search-index.js b/search-index.js index 38455ee..462437b 100644 --- a/search-index.js +++ b/search-index.js @@ -1,4 +1,4 @@ var searchIndex = JSON.parse('{\ -"pages":{"doc":"","t":[17,17,17,17,17,3,3,17,17,12,11,11,0,11,11,5,11,5,0,0,12,0,12,5,0,12,11,11,11,11,3,11,11,11,11,12,11,11,11,11,11,11,11,11,11,0,12,11,5,11,11,11,11,11,11,11,3,11,11,3,11,11,11,11,11,11,11,11,12,11,3,11,11,11,11,3,11,11,11,11,11,11,12,11,11,11,0,11,5,12,11,11,11,11,11,11,11,12,11,11,3,11,11,12,11,12,11,11,11,11,11,11,3,11,11,11,12,11,11,11,11,11,11,11,11,12,12,12,11,11,11,11,11,17,3,11,11,12,11,11,12,11,5,11,11,11,11,3,3,11,11,11,11,5,11,11,11,11,11,11,11,11,11,11,11,11,11,12,11,12,12,12,12,11,11,11,11,11,11,11,11,11,11,12],"n":["CACHE_AGE","GIT_COMMIT_HASH","PKG_DESCRIPTION","PKG_HOMEPAGE","PKG_NAME","SETTINGS","Settings","V1_API_ROUTES","VERSION","__private_field","borrow","borrow_mut","deploy","deref","from","get_json_err","into","main","meta","page","pages","routes","server","services","settings","source_code","try_from","try_into","type_id","vzip","DeployEvent","borrow","borrow","borrow_mut","borrow_mut","branch","clone","clone_into","deserialize","fmt","from","from","into","into","register","routes","secret","serialize","services","to_owned","try_from","try_from","try_into","try_into","type_id","type_id","update","vzip","vzip","Deploy","borrow","borrow_mut","from","into","new","try_from","try_into","type_id","update","vzip","BuildDetails","borrow","borrow","borrow_mut","borrow_mut","build_details","clone","clone_into","deserialize","fmt","from","from","git_commit_hash","into","into","register","routes","serialize","services","source_code","to_owned","try_from","try_from","try_into","try_into","type_id","type_id","version","vzip","vzip","Meta","borrow","borrow_mut","build_details","from","health","into","new","try_from","try_into","type_id","vzip","Page","_fetch_upstream","borrow","borrow_mut","branch","clone","clone_into","create_repo","deserialize","fetch_upstream","fmt","from","into","path","repo","secret","to_owned","try_from","try_into","type_id","vzip","ROUTES","Routes","borrow","borrow_mut","deploy","from","into","meta","new","services","try_from","try_into","type_id","vzip","Server","Settings","borrow","borrow","borrow_mut","borrow_mut","check_url","clone","clone","clone_into","clone_into","deserialize","deserialize","fmt","fmt","from","from","get_ip","into","into","ip","new","pages","port","server","source_code","to_owned","to_owned","try_from","try_from","try_into","try_into","type_id","type_id","vzip","vzip","workers"],"q":["pages","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","pages::deploy","","","","","","","","","","","","","","","","","","","","","","","","","","","","","pages::deploy::routes","","","","","","","","","","","pages::meta","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","pages::meta::routes","","","","","","","","","","","","pages::page","","","","","","","","","","","","","","","","","","","","","pages::routes","","","","","","","","","","","","","","pages::settings","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""],"d":["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","emmits build details of the bninary","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""],"i":[0,0,0,0,0,0,0,0,0,1,1,1,0,1,1,0,1,0,0,0,2,0,2,0,0,2,1,1,1,1,0,3,4,3,4,3,3,3,3,3,3,4,3,4,4,0,3,3,0,3,3,4,3,4,3,4,0,3,4,0,5,5,5,5,5,5,5,5,5,5,0,6,7,6,7,0,6,6,6,6,6,7,6,6,7,7,0,6,0,6,6,6,7,6,7,6,7,6,6,7,0,8,8,8,8,8,8,8,8,8,8,8,0,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,0,0,10,10,10,10,10,10,10,0,10,10,10,10,0,0,11,2,11,2,0,11,2,11,2,11,2,11,2,11,2,11,11,2,11,2,2,11,2,2,11,2,11,2,11,2,11,2,11,2,11],"f":[null,null,null,null,null,null,null,null,null,null,[[]],[[]],null,[[],["settings",3]],[[]],[[],["jsonconfig",3]],[[]],[[],["result",6]],null,null,null,null,null,[[["serviceconfig",3]]],null,null,[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[]],null,[[]],[[]],[[]],[[]],null,[[],["deployevent",3]],[[]],[[],["result",4]],[[["formatter",3]],["result",6]],[[]],[[]],[[]],[[]],[[["appservice",3]]],null,null,[[],["result",4]],[[["serviceconfig",3]]],[[]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[],["typeid",3]],null,[[]],[[]],null,[[]],[[]],[[]],[[]],[[]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],null,[[]],null,[[]],[[]],[[]],[[]],null,[[],["builddetails",3]],[[]],[[],["result",4]],[[["formatter",3]],["result",6]],[[]],[[]],null,[[]],[[]],[[["appservice",3]]],null,[[],["result",4]],[[["serviceconfig",3]]],null,[[]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[],["typeid",3]],null,[[]],[[]],null,[[]],[[]],null,[[]],null,[[]],[[]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[]],null,[[["repository",3],["str",15]]],[[]],[[]],null,[[],["page",3]],[[]],[[],["repository",3]],[[],["result",4]],[[["str",15]]],[[["formatter",3]],["result",6]],[[]],[[]],null,null,null,[[]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[]],null,null,[[]],[[]],null,[[]],[[]],null,[[]],[[["serviceconfig",3]]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[]],null,null,[[]],[[]],[[]],[[]],[[["config",3]]],[[],["server",3]],[[],["settings",3]],[[]],[[]],[[],["result",4]],[[],["result",4]],[[["formatter",3]],["result",6]],[[["formatter",3]],["result",6]],[[]],[[]],[[],["string",3]],[[]],[[]],null,[[],["result",4,[["configerror",4]]]],null,null,null,null,[[]],[[]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[],["typeid",3]],[[]],[[]],null],"p":[[3,"SETTINGS"],[3,"Settings"],[3,"DeployEvent"],[3,"update"],[3,"Deploy"],[3,"BuildDetails"],[3,"build_details"],[3,"Meta"],[3,"Page"],[3,"Routes"],[3,"Server"]]}\ +"pages":{"doc":"","t":[17,17,17,17,17,3,3,17,17,12,11,11,0,11,11,5,11,5,0,0,12,0,12,5,0,12,11,11,11,11,3,11,11,11,11,12,11,11,11,11,11,11,11,11,11,0,12,11,5,11,11,11,11,11,11,11,3,11,11,3,11,11,11,11,11,11,11,11,12,11,3,11,11,11,11,3,11,11,11,11,11,11,12,11,11,11,0,11,5,12,11,11,11,11,11,11,11,12,11,11,3,11,11,12,11,12,11,11,11,11,11,11,3,11,11,11,12,11,11,11,11,11,11,11,11,12,12,12,11,11,11,11,11,17,3,11,11,12,11,11,12,11,5,11,11,11,11,3,3,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,11,12,12,12,12,11,11,11,11,11,11,11,11,11,11,12],"n":["CACHE_AGE","GIT_COMMIT_HASH","PKG_DESCRIPTION","PKG_HOMEPAGE","PKG_NAME","SETTINGS","Settings","V1_API_ROUTES","VERSION","__private_field","borrow","borrow_mut","deploy","deref","from","get_json_err","into","main","meta","page","pages","routes","server","services","settings","source_code","try_from","try_into","type_id","vzip","DeployEvent","borrow","borrow","borrow_mut","borrow_mut","branch","clone","clone_into","deserialize","fmt","from","from","into","into","register","routes","secret","serialize","services","to_owned","try_from","try_from","try_into","try_into","type_id","type_id","update","vzip","vzip","Deploy","borrow","borrow_mut","from","into","new","try_from","try_into","type_id","update","vzip","BuildDetails","borrow","borrow","borrow_mut","borrow_mut","build_details","clone","clone_into","deserialize","fmt","from","from","git_commit_hash","into","into","register","routes","serialize","services","source_code","to_owned","try_from","try_from","try_into","try_into","type_id","type_id","version","vzip","vzip","Meta","borrow","borrow_mut","build_details","from","health","into","new","try_from","try_into","type_id","vzip","Page","_fetch_upstream","borrow","borrow_mut","branch","clone","clone_into","create_repo","deserialize","fetch_upstream","fmt","from","into","path","repo","secret","to_owned","try_from","try_into","type_id","vzip","ROUTES","Routes","borrow","borrow_mut","deploy","from","into","meta","new","services","try_from","try_into","type_id","vzip","Server","Settings","borrow","borrow","borrow_mut","borrow_mut","check_url","clone","clone","clone_into","clone_into","deserialize","deserialize","fmt","fmt","from","from","get_ip","into","into","ip","new","pages","port","server","source_code","to_owned","to_owned","try_from","try_from","try_into","try_into","type_id","type_id","vzip","vzip","workers"],"q":["pages","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","pages::deploy","","","","","","","","","","","","","","","","","","","","","","","","","","","","","pages::deploy::routes","","","","","","","","","","","pages::meta","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","pages::meta::routes","","","","","","","","","","","","pages::page","","","","","","","","","","","","","","","","","","","","","pages::routes","","","","","","","","","","","","","","pages::settings","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""],"d":["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","emmits build details of the bninary","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""],"i":[0,0,0,0,0,0,0,0,0,1,1,1,0,1,1,0,1,0,0,0,2,0,2,0,0,2,1,1,1,1,0,3,4,3,4,3,3,3,3,3,3,4,3,4,4,0,3,3,0,3,3,4,3,4,3,4,0,3,4,0,5,5,5,5,5,5,5,5,5,5,0,6,7,6,7,0,6,6,6,6,6,7,6,6,7,7,0,6,0,6,6,6,7,6,7,6,7,6,6,7,0,8,8,8,8,8,8,8,8,8,8,8,0,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,0,0,10,10,10,10,10,10,10,0,10,10,10,10,0,0,11,2,11,2,2,11,2,11,2,11,2,11,2,11,2,11,11,2,11,2,2,11,2,2,11,2,11,2,11,2,11,2,11,2,11],"f":[null,null,null,null,null,null,null,null,null,null,[[]],[[]],null,[[],["settings",3]],[[]],[[],["jsonconfig",3]],[[]],[[],["result",6]],null,null,null,null,null,[[["serviceconfig",3]]],null,null,[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[]],null,[[]],[[]],[[]],[[]],null,[[],["deployevent",3]],[[]],[[],["result",4]],[[["formatter",3]],["result",6]],[[]],[[]],[[]],[[]],[[["appservice",3]]],null,null,[[],["result",4]],[[["serviceconfig",3]]],[[]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[],["typeid",3]],null,[[]],[[]],null,[[]],[[]],[[]],[[]],[[]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],null,[[]],null,[[]],[[]],[[]],[[]],null,[[],["builddetails",3]],[[]],[[],["result",4]],[[["formatter",3]],["result",6]],[[]],[[]],null,[[]],[[]],[[["appservice",3]]],null,[[],["result",4]],[[["serviceconfig",3]]],null,[[]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[],["typeid",3]],null,[[]],[[]],null,[[]],[[]],null,[[]],null,[[]],[[]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[]],null,[[["repository",3],["str",15]]],[[]],[[]],null,[[],["page",3]],[[]],[[],["repository",3]],[[],["result",4]],[[["str",15]]],[[["formatter",3]],["result",6]],[[]],[[]],null,null,null,[[]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[]],null,null,[[]],[[]],null,[[]],[[]],null,[[]],[[["serviceconfig",3]]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[]],null,null,[[]],[[]],[[]],[[]],[[]],[[],["server",3]],[[],["settings",3]],[[]],[[]],[[],["result",4]],[[],["result",4]],[[["formatter",3]],["result",6]],[[["formatter",3]],["result",6]],[[]],[[]],[[],["string",3]],[[]],[[]],null,[[],["result",4,[["configerror",4]]]],null,null,null,null,[[]],[[]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[],["typeid",3]],[[]],[[]],null],"p":[[3,"SETTINGS"],[3,"Settings"],[3,"DeployEvent"],[3,"update"],[3,"Deploy"],[3,"BuildDetails"],[3,"build_details"],[3,"Meta"],[3,"Page"],[3,"Routes"],[3,"Server"]]}\ }'); if (window.initSearch) {window.initSearch(searchIndex)}; \ No newline at end of file diff --git a/src/pages/settings.rs.html b/src/pages/settings.rs.html index 33ea7f7..2c1b806 100644 --- a/src/pages/settings.rs.html +++ b/src/pages/settings.rs.html @@ -107,11 +107,6 @@ 105 106 107 -108 -109 -110 -111 -112
/*
  * Copyright (C) 2022  Aravinth Manivannan <realaravinth@batsense.net>
  *
@@ -162,34 +157,33 @@
 #[cfg(not(tarpaulin_include))]
 impl Settings {
     pub fn new() -> Result<Self, ConfigError> {
-        let mut s = Config::new();
+        let mut s = Config::builder();
+
         const CURRENT_DIR: &str = "./config/default.toml";
         const ETC: &str = "/etc/static-pages/config.toml";
 
         if let Ok(path) = env::var("PAGES__CONFIG") {
-            s.merge(File::with_name(&path))?;
+            s = s.add_source(File::with_name(&path));
         } else if Path::new(CURRENT_DIR).exists() {
             // merging default config from file
-            s.merge(File::with_name(CURRENT_DIR))?;
+            s = s.add_source(File::with_name(CURRENT_DIR));
         } else if Path::new(ETC).exists() {
-            s.merge(File::with_name(ETC))?;
+            s = s.add_source(File::with_name(ETC));
         } else {
             log::warn!("configuration file not found");
         }
 
-        s.merge(Environment::with_prefix("PAGES").separator("__"))?;
-
-        check_url(&s);
+        s = s.add_source(Environment::with_prefix("PAGES").separator("__"));
 
+        let mut settings = s.build()?.try_deserialize::<Settings>()?;
+        settings.check_url();
         match env::var("PORT") {
             Ok(val) => {
-                s.set("server.port", val).unwrap();
+                settings.server.port = val.parse().unwrap();
             }
             Err(e) => warn!("couldn't interpret PORT: {}", e),
         }
 
-        let settings: Settings = s.try_into()?;
-
         for (index, page) in settings.pages.iter().enumerate() {
             Url::parse(&page.repo).unwrap();
             let path = Path::new(&page.path);
@@ -214,15 +208,11 @@
 
         Ok(settings)
     }
-}
 
-#[cfg(not(tarpaulin_include))]
-fn check_url(s: &Config) {
-    let url = s
-        .get::<String>("source_code")
-        .expect("Couldn't access source_code");
-
-    Url::parse(&url).expect("Please enter a URL for source_code in settings");
+    #[cfg(not(tarpaulin_include))]
+    fn check_url(&self) {
+        Url::parse(&self.source_code).expect("Please enter a URL for source_code in settings");
+    }
 }