#configuration #codes

custom_codes

Simple uniform response and error codes backed by enums

18 stable releases

✓ Uses Rust 2018 edition

1.2.10 Mar 15, 2020
1.2.9 Mar 10, 2020
1.2.6 Feb 29, 2020
1.2.3 Jan 6, 2020
1.0.2 Jul 13, 2019

#24 in Configuration

Download history 156/week @ 2019-12-08 1/week @ 2019-12-15 10/week @ 2019-12-22 1/week @ 2019-12-29 20/week @ 2020-01-05 92/week @ 2020-01-12 3/week @ 2020-01-19 1/week @ 2020-01-26 3/week @ 2020-02-02 15/week @ 2020-02-09 22/week @ 2020-02-16 94/week @ 2020-02-23 20/week @ 2020-03-01 81/week @ 2020-03-08 53/week @ 2020-03-15 90/week @ 2020-03-22

122 downloads per month
Used in 4 crates

Apache-2.0

26KB
359 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–1MB
~24K SLoC