email_encoding/body/
mod.rs1use std::ops::Deref;
4
5pub mod base64;
6mod chooser;
7
8#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
10pub enum Encoding {
11    SevenBit,
13    EightBit,
15    QuotedPrintable,
17    Base64,
19}
20
21#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
23pub enum StrOrBytes<'a> {
24    Str(&'a str),
26    Bytes(&'a [u8]),
28}
29
30impl<'a> From<&'a str> for StrOrBytes<'a> {
31    fn from(s: &'a str) -> Self {
32        Self::Str(s)
33    }
34}
35
36impl<'a> From<&'a [u8]> for StrOrBytes<'a> {
37    fn from(s: &'a [u8]) -> Self {
38        Self::Bytes(s)
39    }
40}
41
42impl<'a, const N: usize> From<&'a [u8; N]> for StrOrBytes<'a> {
43    fn from(s: &'a [u8; N]) -> Self {
44        Self::Bytes(s)
45    }
46}
47
48impl<'a> Deref for StrOrBytes<'a> {
49    type Target = [u8];
50
51    fn deref(&self) -> &Self::Target {
52        match self {
53            Self::Str(s) => s.as_bytes(),
54            Self::Bytes(b) => b,
55        }
56    }
57}