|
| 1 | +/* |
| 2 | + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + */ |
| 5 | + |
| 6 | +/// The level of checksum validation performed on a download |
| 7 | +#[derive(Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord)] |
| 8 | +pub enum ChecksumValidationLevel { |
| 9 | + /// Checksum validation was not performed on all downloaded data. |
| 10 | + /// |
| 11 | + /// Note this DOES NOT mean the checksum didn't match. That would have failed the download with a |
| 12 | + /// [ChecksumMismatch] error. |
| 13 | + /// |
| 14 | + /// There are many reasons for `NotValidated`, including: |
| 15 | + /// - The object had no checksum. |
| 16 | + /// - Objects uploaded before 2025 are unlikely to have a checksum. |
| 17 | + /// In late-2024/early-2025 Amazon S3 began automatically calculating and storing checksums ([blog post]). |
| 18 | + /// The exact date for this varies by region. |
| 19 | + /// - Third parties that mimic the Amazon S3 API may not provide a checksum. |
| 20 | + /// - The object was downloaded in chunks, and one or more chunks had no checksum. |
| 21 | + /// - This happens when a large object with a [FullObject checksum][ChecksumTypes] |
| 22 | + /// is downloaded in multiple chunks. |
| 23 | + /// - This happens when an object with a [Composite checksum][ChecksumTypes] |
| 24 | + /// is downloaded in chunks that don't align with the [PartSize] it was uploaded with. |
| 25 | + /// - Checksum validation was disabled in the underlying The S3 client, |
| 26 | + /// by configuring it with the non-default |
| 27 | + /// [`aws_sdk_s3::config::ResponseChecksumValidation::WhenRequired`]. |
| 28 | + /// |
| 29 | + /// [ChecksumMismatch]: https://docs.rs/aws-smithy-checksums/latest/aws_smithy_checksums/body/validate/enum.Error.html#variant.ChecksumMismatch |
| 30 | + /// [ChecksumTypes]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html#ChecksumTypes |
| 31 | + /// [blog post]: https://aws.amazon.com/blogs/aws/introducing-default-data-integrity-protections-for-new-objects-in-amazon-s3/ |
| 32 | + /// [PartSize]: crate::types::PartSize |
| 33 | + #[default] |
| 34 | + NotValidated, |
| 35 | + /// The checksum of each downloaded chunk was validated, but the |
| 36 | + /// [FullObject or Composite checksum][ChecksumTypes] for the whole object |
| 37 | + /// was not validated. |
| 38 | + /// |
| 39 | + /// This can happen if: |
| 40 | + /// - A large object is downloaded in multiple chunks. |
| 41 | + /// - You requested a range of the object to download, not the full object. |
| 42 | + /// |
| 43 | + /// [ChecksumTypes]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html#ChecksumTypes |
| 44 | + AllChunks, |
| 45 | + /// The full object was downloaded, and its checksum was validated. |
| 46 | + FullObject, |
| 47 | +} |
0 commit comments