Vendor dependencies

This commit is contained in:
2026-08-01 16:11:49 +03:00
parent 7f139a0241
commit 6b5e7f0f8b
29706 changed files with 9575646 additions and 0 deletions
+57
View File
@@ -0,0 +1,57 @@
//! Email body encoding algorithms.
use core::ops::Deref;
pub mod base64;
mod chooser;
/// A possible email `Content-Transfer-Encoding`
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum Encoding {
/// 7bit (US-ASCII)
SevenBit,
/// 8bit (UTF-8)
EightBit,
/// [Quoted Printable](https://docs.rs/quoted_printable/0.4.5/quoted_printable/fn.encode_to_str.html)
QuotedPrintable,
/// [Base64](self::base64::encode)
Base64,
}
/// A borrowed `str` or `[u8]`
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum StrOrBytes<'a> {
/// `str` variant
Str(&'a str),
/// `[u8]` variant
Bytes(&'a [u8]),
}
impl<'a> From<&'a str> for StrOrBytes<'a> {
fn from(s: &'a str) -> Self {
Self::Str(s)
}
}
impl<'a> From<&'a [u8]> for StrOrBytes<'a> {
fn from(s: &'a [u8]) -> Self {
Self::Bytes(s)
}
}
impl<'a, const N: usize> From<&'a [u8; N]> for StrOrBytes<'a> {
fn from(s: &'a [u8; N]) -> Self {
Self::Bytes(s)
}
}
impl Deref for StrOrBytes<'_> {
type Target = [u8];
fn deref(&self) -> &Self::Target {
match self {
Self::Str(s) => s.as_bytes(),
Self::Bytes(b) => b,
}
}
}