#configuration #codes

custom_codes

Simple uniform response and error codes backed by enums

11 stable releases

✓ Uses Rust 2018 edition

1.2.3 Jan 6, 2020
1.2.2 Oct 31, 2019
1.1.0 Sep 15, 2019
1.0.3 Aug 25, 2019
1.0.2 Jul 13, 2019

#23 in Value formatting

Download history 9/week @ 2019-10-05 9/week @ 2019-10-12 17/week @ 2019-10-19 73/week @ 2019-10-26 39/week @ 2019-11-02 4/week @ 2019-11-09 21/week @ 2019-11-16 16/week @ 2019-11-23 20/week @ 2019-11-30 146/week @ 2019-12-07 11/week @ 2019-12-14 10/week @ 2019-12-28 19/week @ 2020-01-04 94/week @ 2020-01-11

123 downloads per month
Used in 2 crates

Apache-2.0

25KB
346 lines

custom_codes

This are Custom Enums for memorable and uniform response codes.

Enums are cheaper to compare and harder to get wrong than strings thereby guaranteeing efficiency.

Examples

Create codes for File Operations

use custom_codes::FileOps; 

fn create_file(file_name: &str) -> FileOps {
    match std::fs::File::create(file_name) {
        Ok(_) => FileOps::CreateTrue,
        Err(_) => FileOps::CreateFalse,
	}
}

fn main() {
	open("foo.txt");
}

lib.rs:

This are Custom Enum codes for memorable and uniform response codes. Enums are cheaper to compare and harder to get wrong than strings thereby guaranteeing efficiency.

Examples

Create codes for File Operations

use custom_codes::FileOps;

fn open_file(file_name: &str) -> FileOps {
    match std::fs::File::create(file_name) {
        Ok(_) => FileOps::CreateTrue,
        Err(_) => FileOps::CreateFalse,
    }
}
fn main() {
    open_file("foo.txt");
}

Dependencies

~0.7–1.1MB
~26K SLoC