#env #dotenv #applications #environment #loading #modular

kankyo

Simple, efficient, and precise .env library

4 releases (2 breaking)

Uses old Rust 2015

0.3.0 Jul 5, 2019
0.2.0 Jan 21, 2018
0.1.1 Dec 6, 2017
0.1.0 Oct 24, 2017

#802 in Configuration

Download history 115/week @ 2024-07-22 110/week @ 2024-07-29 76/week @ 2024-08-05 142/week @ 2024-08-12 75/week @ 2024-08-19 102/week @ 2024-08-26 77/week @ 2024-09-02 73/week @ 2024-09-09 50/week @ 2024-09-16 112/week @ 2024-09-23 88/week @ 2024-09-30 3/week @ 2024-10-07 71/week @ 2024-10-14 58/week @ 2024-10-21 88/week @ 2024-10-28 68/week @ 2024-11-04

285 downloads per month
Used in 5 crates

ISC license

23KB
218 lines

ci-badge license-badge docs-badge rust badge

kankyo is a crate for the loading and unloading of .env files or other readers into and from the environment.

This crate is meant to be a more modular and efficient, yet concise collection of functions exposed for any custom requirement. Due to its design, it is applicable in both synchronous and asynchronous applications.

Installation

This library requires at least Rust 1.0.0.

Add the following dependency to your project's Cargo.toml:

kankyo = "0.3"

What are .env files?

Environment variable files, often named .env, are files usually located at the project root. The contents of the file are = (equals sign)-delimited lines of key-value pairs. A sample file might look like:

DEBUG=info
DB_HOST=127.0.0.1 # This is a comment, not parsed as part of the value.

# Empty lines are ignored, as are lines solely consisting of a comment.

Usage

The library works with interfacing over readers (types implementing the std::io::Read trait), meaning that you can pass slices of bytes, strings, files, etc. to it.

For example, opening a file and parsing its contents into the environment:

extern crate kankyo;

use std::fs::File;

kankyo::load_from_reader(File::open("./.env")?)?;

println!("Loaded!");

Due to the common nature of this operation, a function that does precisely this is offered:

extern crate kankyo;

kankyo::load()?;

println!("Loaded!");

License

License info in LICENSE.md. Long story short, ISC.

No runtime deps