feat(core): flesh out DocumentCore
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,40 @@
|
|||||||
|
//! Document: filename + mime + pointer to the primary attachment blob.
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
|
||||||
pub struct DocumentCore {}
|
use crate::ids::AttachmentId;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct DocumentCore {
|
||||||
|
pub filename: String,
|
||||||
|
pub mime_type: String,
|
||||||
|
pub primary_attachment: AttachmentId,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for DocumentCore {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
filename: String::new(),
|
||||||
|
mime_type: "application/octet-stream".into(),
|
||||||
|
primary_attachment: AttachmentId(String::new()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn document_round_trip() {
|
||||||
|
let doc = DocumentCore {
|
||||||
|
filename: "passport.pdf".into(),
|
||||||
|
mime_type: "application/pdf".into(),
|
||||||
|
primary_attachment: AttachmentId("0123456789abcdef".into()),
|
||||||
|
};
|
||||||
|
let json = serde_json::to_string(&doc).unwrap();
|
||||||
|
let parsed: DocumentCore = serde_json::from_str(&json).unwrap();
|
||||||
|
assert_eq!(parsed.filename, "passport.pdf");
|
||||||
|
assert_eq!(parsed.primary_attachment.as_str(), "0123456789abcdef");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user