#configuration #codes

custom_codes

Simple uniform response and error codes backed by enums

22 stable releases

✓ Uses Rust 2018 edition

2.0.3 Jun 25, 2020
1.2.10 Mar 15, 2020
1.2.2 Oct 31, 2019
1.0.2 Jul 13, 2019

#23 in Configuration

Download history 59/week @ 2020-03-14 72/week @ 2020-03-21 27/week @ 2020-03-28 21/week @ 2020-04-04 114/week @ 2020-04-11 14/week @ 2020-04-18 3/week @ 2020-04-25 1/week @ 2020-05-02 2/week @ 2020-05-09 35/week @ 2020-05-16 33/week @ 2020-05-23 48/week @ 2020-05-30 27/week @ 2020-06-06 24/week @ 2020-06-13 14/week @ 2020-06-20 31/week @ 2020-06-27

116 downloads per month
Used in less than 7 crates

Apache-2.0

43KB
639 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.6–1.1MB
~25K SLoC