pub fn decrypt_safe(text: &str, shift: i16) -> Result<String, CipherError>Expand description
Decrypts text using Caesar cipher with error handling
This function validates input values and returns an error for invalid inputs.
Internally uses decrypt after validation, so fixes in decrypt
are automatically reflected in this safe API.
§Arguments
text- Text to decrypt (must not be empty or whitespace-only)shift- Shift value to use for decryption (must be in range -25 to 25)
§Returns
Decrypted text on success, CipherError on failure
§Errors
CipherError::EmptyText- When text is empty or whitespace-onlyCipherError::InvalidShift- When shift value is out of range
§Examples
use caesar_cipher_enc_dec::caesar_cipher::decrypt_safe;
let result = decrypt_safe("Khoor", 3).unwrap();
assert_eq!(result, "Hello");