Skip to content

Commit aca9a56

Browse files
committed
refactor: rename environment variables from ZINC to CONF and update license year
1 parent 759ea10 commit aca9a56

File tree

9 files changed

+38
-38
lines changed

9 files changed

+38
-38
lines changed

.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
ZINC_ENABLE=false
2-
ZINC_NUMBER=88888
1+
CONF_ENABLE=false
2+
CONF_NUMBER=88888

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "dotenv_config"
3-
version = "0.2.2"
4-
edition = "2021"
3+
version = "0.2.3"
4+
edition = "2024"
55
authors = ["Hengfei Yang <hengfei.yang@gmail.com>"]
66
description = "parse `env` to config struct for Rust"
77
homepage = "https://github.com/openobserve/dotenv-config/"

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 Zinc Labs Inc.
3+
Copyright (c) 2026 OpenObserve Inc.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ struct Config {
3535
#[env_config(default = "192.168.2.1")]
3636
server_addr: String,
3737
server_mode: bool,
38-
#[env_config(name = "ZINC_ENABLE", default = true)]
38+
#[env_config(name = "CONF_ENABLE", default = true)]
3939
enable: bool,
40-
#[env_config(name = "ZINC_NUMBER", default = 123456, help = "this is for demo")]
40+
#[env_config(name = "CONF_NUMBER", default = 123456, help = "this is for demo")]
4141
num: Option<i64>,
4242
#[env_config(parse, default = "green")] // or parse=true
4343
color: Color,
@@ -64,15 +64,15 @@ you can use macro attribute set field attribute
6464
## you can though system environments or `.env` file config it.
6565

6666
```
67-
ZINC_ENABLE=false
68-
ZINC_NUMBER=8787878
67+
CONF_ENABLE=false
68+
CONF_NUMBER=8787878
6969
```
7070

7171
default load environment key is: `structName_fieldName` do UpperSnake, like above struct, default config key is:
7272

7373
```
7474
CONFIG_SERVER_ADDR
7575
CONFIG_SERVER_MODE
76-
ZINC_ENABLE
77-
ZINC_NUMBER
76+
CONF_ENABLE
77+
CONF_NUMBER
7878
```

examples/config.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ use dotenvy::dotenv;
33

44
#[derive(Debug, EnvConfig)]
55
struct Config {
6-
#[env_config(name = "ZINC_SERVER_ADDR", default = "192.168.2.1")]
6+
#[env_config(name = "CONF_SERVER_ADDR", default = "192.168.2.1")]
77
server_addr: String,
88
server_mode: bool,
9-
#[env_config(name = "ZINC_ENABLE", default = true)]
9+
#[env_config(name = "CONF_ENABLE", default = true)]
1010
enable: bool,
11-
#[env_config(name = "ZINC_NUMBER", default = 123456)]
11+
#[env_config(name = "CONF_NUMBER", default = 123456)]
1212
num: Option<i64>,
1313
rr: Redis,
1414
}
@@ -18,7 +18,7 @@ struct Redis {
1818
addr: String,
1919
port: String,
2020
auth: String,
21-
#[env_config(name = "ZINC_REDIS_TIMEOUT", default = 30)]
21+
#[env_config(name = "CONF_REDIS_TIMEOUT", default = 30)]
2222
timeout: i32,
2323
}
2424

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[toolchain]
2-
channel = "1.85.0"
2+
channel = "1.91.0"

src/builder.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2022 Zinc Labs Inc. and Contributors
1+
/* Copyright 2026 OpenObserve Inc. and Contributors
22
*
33
* Licensed under the Apache License, Version 2.0 (the "License");
44
* you may not use this file except in compliance with the License.
@@ -149,10 +149,10 @@ impl BuilderContext {
149149
fn split(input: TokenStream) -> (Ident, TokenStream) {
150150
let mut input = input.into_iter().collect::<VecDeque<_>>();
151151
while let Some(item) = input.pop_front() {
152-
if let TokenTree::Ident(v) = item {
153-
if v.to_string() == "struct" {
154-
break;
155-
}
152+
if let TokenTree::Ident(v) = item
153+
&& v.to_string() == "struct"
154+
{
155+
break;
156156
}
157157
}
158158

src/lib.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2022 Zinc Labs Inc. and Contributors
1+
/* Copyright 2026 OpenObserve Inc. and Contributors
22
*
33
* Licensed under the Apache License, Version 2.0 (the "License");
44
* you may not use this file except in compliance with the License.
@@ -31,9 +31,9 @@
3131
//! #[env_config(default = "192.168.2.1")]
3232
//! server_addr: String,
3333
//! server_mode: bool,
34-
//! #[env_config(name = "ZINC_ENABLE", default = true)]
34+
//! #[env_config(name = "CONF_ENABLE", default = true)]
3535
//! enable: bool,
36-
//! #[env_config(name = "ZINC_NUMBER", default = 123456)]
36+
//! #[env_config(name = "CONF_NUMBER", default = 123456)]
3737
//! num: Option<i64>,
3838
//! }
3939
//!
@@ -56,21 +56,21 @@
5656
//! ## you can though system environments or `.env` file config it.
5757
//!
5858
//! ```ignore
59-
//! ZINC_ENABLE=false
60-
//! ZINC_NUMBER=8787878
59+
//! CONF_ENABLE=false
60+
//! CONF_NUMBER=8787878
6161
//! ```
6262
//!
6363
//! default load environment key is: `structName_fieldName` do UpperSnake, like above struct, default config key is:
6464
//!
6565
//! ```ignore
66-
//! CONFIG_SERVER_ADDR
67-
//! CONFIG_SERVER_MODE
68-
//! ZINC_ENABLE
69-
//! ZINC_NUMBER
66+
//! CONF_SERVER_ADDR
67+
//! CONF_SERVER_MODE
68+
//! CONF_ENABLE
69+
//! CONF_NUMBER
7070
//! ```
7171
//!
7272
//! If you have some problems please go to github create a issue.
73-
//! https://github.com/zinclabs/dotenv-config
73+
//! https://github.com/openobserve/dotenv-config
7474
//!
7575
7676
use proc_macro::TokenStream;

tests/config.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ struct Config {
2626
#[env_config(default = "192.168.2.1")]
2727
server_addr: String,
2828
server_mode: bool,
29-
#[env_config(name = "ZINC_ENABLE", default = true, help = "this is important")]
29+
#[env_config(name = "CONF_ENABLE", default = true, help = "this is important")]
3030
enable: bool,
31-
#[env_config(name = "ZINC_NUMBER", default = 123456)]
31+
#[env_config(name = "CONF_NUMBER", default = 123456)]
3232
num: Option<i64>,
3333
rr: Redis,
3434
#[env_config(parse, default = "green")]
@@ -40,7 +40,7 @@ struct Redis {
4040
addr: String,
4141
port: String,
4242
auth: String,
43-
#[env_config(name = "ZINC_REDIS_TIMEOUT", default = 30)]
43+
#[env_config(name = "CONF_REDIS_TIMEOUT", default = 30)]
4444
timeout: i32,
4545
}
4646

@@ -60,14 +60,14 @@ fn test_config() {
6060

6161
let help_keys = Config::get_help();
6262
println!("help_keys: {:?}", help_keys);
63-
assert!(help_keys.contains_key("ZINC_ENABLE"));
64-
assert!(help_keys.contains_key("ZINC_NUMBER"));
63+
assert!(help_keys.contains_key("CONF_ENABLE"));
64+
assert!(help_keys.contains_key("CONF_NUMBER"));
6565

66-
let keys = help_keys.get("ZINC_NUMBER").unwrap();
66+
let keys = help_keys.get("CONF_NUMBER").unwrap();
6767
assert_eq!(keys.0, "123456"); // default value
6868
assert_eq!(keys.1, None); // help value
6969

70-
let keys = help_keys.get("ZINC_ENABLE").unwrap();
70+
let keys = help_keys.get("CONF_ENABLE").unwrap();
7171
assert_eq!(keys.0, "true"); // default value
7272
assert_eq!(keys.1, Some("this is important".to_string())); // help value
7373
}

0 commit comments

Comments
 (0)