Crate custom_codes

Source
Expand description

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");

Macros§

downcast
Try downcasting any error to std::io::Error

Structs§

StringifyError
Convert a String, &'_ str, OsStr or OsString into this type to enable downcasting to a string

Enums§

AccessStatus
re-exports Access status of token or access
ActivityStatus
re-exports Status of an activity
ActivityToggle
re-exports Initialize an activity
Cli
re-exports Command Line Options
Compression
re-exports Compression of files, bytes or directories
CustomBool
re-exports Creates a custom boolean value with more features than a Rustlang boolean which has only true or false
DateTimeOp
re-exports Date and time custom codes
DbOps
re-exports Custom Response Codes Using Enums For Efficient Comparison
DownCastErrors
All common errors for use in crates. They mirror std::io::ErrorKind;
ExecCommand
re-exports Command Operations for execution
FileOps
re-exports File operations
GenericOutcome
re-exports Give the Generic Outcome of an operation with custom result as a generic
HardwareResources
re-exports Hardware Resources of a physical computer
KeyLength
re-exports The length of a key in bytes needed by a cryptography algorithm
Networking
re-exports Networking Specific
Outcome
re-exports Give the Outcome of an operation
SecHardware
re-exports Hardware security access
SecOps
re-exports Security operations on encryption and keys
Subscription
re-exports Status of a subscription that happens over a timespec

Functions§

try_downcast
This method tries to downcast an anyhow::Error to return a DownCastErrors enum for common error handling