amazon_cloudfront_client_routing_lib/
errors.rs1use std::fmt;
5
6#[derive(Debug, Copy, Clone)]
21pub struct DecodeLengthError {
22 pub num_chars: usize,
23 pub expected_num_chars: usize,
24}
25
26impl std::error::Error for DecodeLengthError {}
27
28impl fmt::Display for DecodeLengthError {
29 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
30 write!(
31 f,
32 "Passed {} - expected {} characters",
33 self.num_chars, self.expected_num_chars,
34 )
35 }
36}
37
38#[cfg(test)]
39mod tests {
40 use super::DecodeLengthError;
41
42 #[test]
43 fn validate_decode_length_error_text() {
44 let error = DecodeLengthError {
45 num_chars: 10,
46 expected_num_chars: 29,
47 };
48
49 assert_eq!(error.to_string(), "Passed 10 - expected 29 characters");
50 }
51}