aws_smithy_checksums/
error.rs

1/*
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
6use std::error::Error;
7use std::fmt;
8
9/// A checksum algorithm was unknown
10#[derive(Debug)]
11pub struct UnknownChecksumAlgorithmError {
12    checksum_algorithm: String,
13}
14
15impl UnknownChecksumAlgorithmError {
16    pub(crate) fn new(checksum_algorithm: impl Into<String>) -> Self {
17        Self {
18            checksum_algorithm: checksum_algorithm.into(),
19        }
20    }
21
22    /// The checksum algorithm that is unknown
23    pub fn checksum_algorithm(&self) -> &str {
24        &self.checksum_algorithm
25    }
26}
27
28impl fmt::Display for UnknownChecksumAlgorithmError {
29    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
30        write!(
31            f,
32            r#"unknown checksum algorithm "{}", please pass a known algorithm name ("crc32", "crc32c", "sha1", "sha256", "md5")"#,
33            self.checksum_algorithm
34        )
35    }
36}
37
38impl Error for UnknownChecksumAlgorithmError {}