#configuration #codes

custom_codes

Simple uniform response and error codes backed by enums

23 stable releases

2.0.4 Jul 31, 2020
2.0.2 May 22, 2020
1.2.10 Mar 15, 2020
1.2.2 Oct 31, 2019
1.0.2 Jul 13, 2019

#126 in Value formatting

Download history 75/week @ 2023-10-28 25/week @ 2023-11-04 48/week @ 2023-11-11 18/week @ 2023-11-18 67/week @ 2023-11-25 55/week @ 2023-12-02 19/week @ 2023-12-09 40/week @ 2023-12-16 61/week @ 2023-12-23 12/week @ 2023-12-30 39/week @ 2024-01-06 24/week @ 2024-01-13 52/week @ 2024-01-20 78/week @ 2024-01-27 36/week @ 2024-02-03 93/week @ 2024-02-10

268 downloads per month
Used in 7 crates

Apache-2.0

44KB
644 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,
    }
}

open_file("foo.txt");

Dependencies

~0.5–1.1MB
~26K SLoC