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§
- Stringify
Error - Convert a
String
,&'_ str
,OsStr
orOsString
into this type to enable downcasting to a string
Enums§
- Access
Status - re-exports Access status of token or access
- Activity
Status - re-exports Status of an activity
- Activity
Toggle - re-exports Initialize an activity
- Cli
- re-exports Command Line Options
- Compression
- re-exports Compression of files, bytes or directories
- Custom
Bool - re-exports
Creates a custom
boolean
value with more features than a Rustlang boolean which has onlytrue
orfalse
- Date
Time Op - re-exports Date and time custom codes
- DbOps
- re-exports Custom Response Codes Using Enums For Efficient Comparison
- Down
Cast Errors - All common errors for use in crates. They mirror std::io::ErrorKind;
- Exec
Command - re-exports Command Operations for execution
- FileOps
- re-exports File operations
- Generic
Outcome - re-exports Give the Generic Outcome of an operation with custom result as a generic
- Hardware
Resources - 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 aDownCastErrors
enum for common error handling