Skip to main content

validate_idempotency_key

Function validate_idempotency_key 

Source
pub fn validate_idempotency_key(key: &str) -> Result<(), IdempotencyKeyError>
Expand description

Validate an Idempotency-Key header value.

A key must be non-empty, at most MAX_IDEMPOTENCY_KEY_LEN bytes, and made only of printable ASCII. Empty keys are rejected because they would otherwise become a single key shared by every client.

§Errors

Returns IdempotencyKeyError describing which rule the value broke.

§Examples

use ironflow_api::entities::{IdempotencyKeyError, validate_idempotency_key};

assert!(validate_idempotency_key("github:abc-123").is_ok());
assert_eq!(
    validate_idempotency_key("clé"),
    Err(IdempotencyKeyError::NotPrintableAscii),
);