forked from rustdesk/rustdesk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
477 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Generated by Cargo | ||
# will have compiled files and executables | ||
/target/ | ||
|
||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries | ||
# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock | ||
Cargo.lock | ||
|
||
# These are backup files generated by rustfmt | ||
**/*.rs.bk | ||
|
||
/target | ||
**/*.rs.bk | ||
Cargo.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[package] | ||
name = "confy" | ||
version = "0.4.1" | ||
authors = ["Katharina Fey <[email protected]>"] | ||
description = "Boilerplate-free configuration management" | ||
license = "MIT/X11 OR Apache-2.0" | ||
documentation = "https://docs.rs/confy" | ||
repository = "https://github.com/rust-clique/confy" | ||
edition = "2018" | ||
|
||
[dependencies] | ||
serde = "^1.0" | ||
toml = { version = "^0.5", optional = true } | ||
directories = "^2.0" | ||
serde_yaml = { version = "0.8", optional = true } | ||
|
||
[features] | ||
default = ["toml_conf"] | ||
toml_conf = ["toml"] | ||
yaml_conf = ["serde_yaml"] | ||
|
||
[[example]] | ||
name = "simple" | ||
|
||
[dev-dependencies] | ||
serde_derive = "^1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 rust-clique | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# confy | ||
|
||
Chat with us: [Discord](https://discord.gg/dwq4Zme) | ||
|
||
Zero-boilerplate configuration management. | ||
|
||
Focus on storing the right data, instead of worrying about how or where to store it. | ||
|
||
```rust | ||
use serde_derive::{Serialize, Deserialize}; | ||
|
||
#[derive(Default, Debug, Serialize, Deserialize)] | ||
struct MyConfig { | ||
version: u8, | ||
api_key: String, | ||
} | ||
|
||
fn main() -> Result<(), ::std::io::Error> { | ||
let cfg: MyConfig = confy::load("my-app-name")?; | ||
dbg!(cfg); | ||
Ok(()) | ||
} | ||
``` | ||
|
||
## Using yaml | ||
Enabling the `yaml_conf` feature while disabling the default `toml_conf` | ||
feature causes confy to use a YAML config file instead of TOML. | ||
|
||
``` | ||
[dependencies.confy] | ||
features = ["yaml_conf"] | ||
default-features = false | ||
``` | ||
|
||
## Breakings changes | ||
Starting with version 0.4.0 the configuration file are stored in the expected place for your system. See the [`directories`] crates for more information. | ||
Before version 0.4.0, the configuration file was written in the current directory. | ||
|
||
[`directories`]: https://crates.io/crates/directories |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//! The most simplest examples of how to use confy | ||
extern crate confy; | ||
|
||
#[macro_use] | ||
extern crate serde_derive; | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
struct ConfyConfig { | ||
name: String, | ||
comfy: bool, | ||
foo: i64, | ||
} | ||
|
||
impl Default for ConfyConfig { | ||
fn default() -> Self { | ||
ConfyConfig { | ||
name: "Unknown".to_string(), | ||
comfy: true, | ||
foo: 42, | ||
} | ||
} | ||
} | ||
|
||
fn main() -> Result<(), confy::ConfyError> { | ||
let cfg: ConfyConfig = confy::load("confy_simple_app")?; | ||
println!("{:#?}", cfg); | ||
Ok(()) | ||
} |
Oops, something went wrong.