#configuration #codes

custom_codes

Simple uniform response and error codes backed by enums

10 stable releases

✓ Uses Rust 2018 edition

1.2.2 Oct 31, 2019
1.2.0 Oct 29, 2019
1.1.0 Sep 15, 2019
1.0.3 Aug 25, 2019
1.0.2 Jul 13, 2019

#19 in Value formatting

Download history 7/week @ 2019-07-18 4/week @ 2019-07-25 16/week @ 2019-08-01 9/week @ 2019-08-08 1/week @ 2019-08-15 29/week @ 2019-08-22 29/week @ 2019-08-29 28/week @ 2019-09-05 44/week @ 2019-09-12 96/week @ 2019-09-19 20/week @ 2019-09-26 16/week @ 2019-10-03 19/week @ 2019-10-17 46/week @ 2019-10-24

123 downloads per month
Used in 2 crates

Apache-2.0

23KB
314 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 create_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.8–1.2MB
~27K SLoC