1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
use is_macro::Is;
use serde::Serialize;

pub mod data;
pub mod file;
pub mod front_side;
pub mod reverse_side;
pub mod selfie;
pub mod translation_file;
pub mod unspecified;

pub use {
    data::Data,
    file::{File, Files},
    front_side::FrontSide,
    reverse_side::ReverseSide,
    selfie::Selfie,
    translation_file::{TranslationFile, TranslationFiles},
    unspecified::Unspecified,
};

/// Reperesents possible sources of an error.
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, Serialize, Is)]
#[serde(rename_all = "snake_case", tag = "source")]
#[non_exhaustive]
#[must_use]
pub enum Source<'a> {
    /// An error with data.
    Data(Data<'a>),
    /// An error with a front side.
    FrontSide(FrontSide<'a>),
    /// An error with a reverse side.
    ReverseSide(ReverseSide<'a>),
    /// An error with a selfie.
    Selfie(Selfie<'a>),
    /// An error with a file.
    File(File<'a>),
    /// An error with several files.
    Files(Files<'a>),
    /// An error with a translation file.
    TranslationFile(TranslationFile<'a>),
    /// An error with translation files.
    TranslationFiles(TranslationFiles<'a>),
    /// An unspecified error.
    Unspecified(Unspecified<'a>),
}

impl<'a> From<Data<'a>> for Source<'a> {
    fn from(source: Data<'a>) -> Self {
        Self::Data(source)
    }
}

impl<'a> From<FrontSide<'a>> for Source<'a> {
    fn from(source: FrontSide<'a>) -> Self {
        Self::FrontSide(source)
    }
}

impl<'a> From<ReverseSide<'a>> for Source<'a> {
    fn from(source: ReverseSide<'a>) -> Self {
        Self::ReverseSide(source)
    }
}

impl<'a> From<Selfie<'a>> for Source<'a> {
    fn from(source: Selfie<'a>) -> Self {
        Self::Selfie(source)
    }
}

impl<'a> From<File<'a>> for Source<'a> {
    fn from(source: File<'a>) -> Self {
        Self::File(source)
    }
}

impl<'a> From<Files<'a>> for Source<'a> {
    fn from(source: Files<'a>) -> Self {
        Self::Files(source)
    }
}

impl<'a> From<TranslationFile<'a>> for Source<'a> {
    fn from(source: TranslationFile<'a>) -> Self {
        Self::TranslationFile(source)
    }
}

impl<'a> From<TranslationFiles<'a>> for Source<'a> {
    fn from(source: TranslationFiles<'a>) -> Self {
        Self::TranslationFiles(source)
    }
}

impl<'a> From<Unspecified<'a>> for Source<'a> {
    fn from(source: Unspecified<'a>) -> Self {
        Self::Unspecified(source)
    }
}