http_client_multipart/
encoding.rs1use base64::Engine;
2
3#[derive(Debug, Clone, Copy)]
4pub enum Encoding {
5 SevenBit,
6 EightBit,
7 Base64,
8 QuotedPrintable,
9}
10
11impl Encoding {
12 pub fn to_str(self) -> &'static str {
13 match self {
14 Encoding::SevenBit => "7bit",
15 Encoding::EightBit => "8bit",
16 Encoding::Base64 => "base64",
17 Encoding::QuotedPrintable => "quoted-printable",
18 }
19 }
20
21 pub fn encode(self, input: &mut Vec<u8>) {
22 match self {
23 Encoding::Base64 => {
24 *input = base64::engine::general_purpose::STANDARD_NO_PAD
25 .encode(&input)
26 .into_bytes()
27 }
28 Encoding::QuotedPrintable => *input = quoted_printable::encode(&input),
29 Encoding::SevenBit | Encoding::EightBit => (),
30 }
31 }
32}