[core] Tests: the mandatory suites, red against the API stubs (55 tests)
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
//! Composing outgoing mail (mail-builder), and the drafts for reply, reply all and forward.
|
||||
|
||||
use crate::{Address, Parsed};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Default)]
|
||||
pub struct Draft {
|
||||
pub from: Address,
|
||||
pub to: Vec<Address>,
|
||||
pub cc: Vec<Address>,
|
||||
pub bcc: Vec<Address>,
|
||||
pub subject: String,
|
||||
/// Line endings are `\n`.
|
||||
pub text: String,
|
||||
pub html: Option<String>,
|
||||
pub attachments: Vec<OutAttachment>,
|
||||
/// Without angle brackets.
|
||||
pub in_reply_to: Option<String>,
|
||||
pub references: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct OutAttachment {
|
||||
pub filename: String,
|
||||
pub content_type: String,
|
||||
pub data: Vec<u8>,
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for Draft {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_struct("Draft")
|
||||
.field("to", &self.to.len())
|
||||
.field("attachments", &self.attachments.len())
|
||||
.finish_non_exhaustive()
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for OutAttachment {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_struct("OutAttachment").field("bytes", &self.data.len()).finish_non_exhaustive()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum ReplyMode {
|
||||
Sender,
|
||||
All,
|
||||
}
|
||||
|
||||
/// A Message-ID from 16 random bytes the caller supplies and the sender's domain, without brackets.
|
||||
pub fn message_id(random: [u8; 16], domain: &str) -> String {
|
||||
let _ = (random, domain);
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// The RFC 5322 bytes of `draft`, with the given Message-ID (no brackets) and Date (Unix seconds).
|
||||
pub fn compose(draft: &Draft, message_id: &str, date: i64) -> Vec<u8> {
|
||||
let _ = (draft, message_id, date);
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub fn reply(original: &Parsed, me: &Address, mode: ReplyMode) -> Draft {
|
||||
let _ = (original, me, mode);
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub fn forward(original: &Parsed, me: &Address) -> Draft {
|
||||
let _ = (original, me);
|
||||
todo!()
|
||||
}
|
||||
Reference in New Issue
Block a user