1use aws_sdk_s3::{error::SdkError, primitives::ByteStreamError};
2use std::{fmt::Debug, io};
3
4#[derive(Debug)]
5pub enum S3FilesystemError<E, R> {
7 S3(SdkError<E, R>),
9 ByteStream(ByteStreamError),
11 Io(io::Error),
13}
14
15impl<E, R> From<io::Error> for S3FilesystemError<E, R> {
16 fn from(err: io::Error) -> Self {
17 Self::Io(err)
18 }
19}
20
21impl<E, R> From<SdkError<E, R>> for S3FilesystemError<E, R> {
22 fn from(err: SdkError<E, R>) -> Self {
23 Self::S3(err)
24 }
25}
26
27impl<E, R> From<ByteStreamError> for S3FilesystemError<E, R> {
28 fn from(err: ByteStreamError) -> Self {
29 Self::ByteStream(err)
30 }
31}
32impl<E, R> std::fmt::Display for S3FilesystemError<E, R> {
33 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
34 match self {
35 S3FilesystemError::S3(s3_err) => write!(f, "S3 Error: {}", s3_err),
36 S3FilesystemError::Io(io_err) => write!(f, "IO Error: {}", io_err),
37 S3FilesystemError::ByteStream(bytestream_error) => {
38 write!(f, "ByteStream error: {}", bytestream_error)
39 }
40 }
41 }
42}
43impl<E, R> std::error::Error for S3FilesystemError<E, R>
44where
45 E: std::error::Error + 'static,
46 R: Debug,
47{
48}