An ATProtocol powered blogging engine.
1use chrono::{DateTime, Utc};
2use serde::Deserialize;
3
4/// A blob record containing binary data metadata.
5#[derive(Debug, Clone, Deserialize)]
6pub struct BlobRecord {
7 /// The record type
8 #[serde(rename = "$type")]
9 pub r#type: String,
10
11 /// MIME type of the blob
12 #[serde(rename = "mimeType")]
13 pub mime_type: String,
14 /// Size of the blob in bytes
15 pub size: i64,
16
17 /// Reference to the blob content
18 #[serde(rename = "ref")]
19 pub r#ref: BlobRef,
20}
21
22/// A reference to blob content via CID link.
23#[derive(Debug, Clone, Deserialize)]
24pub struct BlobRef {
25 /// The CID link to the blob content
26 #[serde(rename = "$link")]
27 pub link: String,
28}
29
30/// An attachment to a blog post.
31#[derive(Debug, Clone, Deserialize)]
32pub struct PostAttachment {
33 /// The attachment type
34 #[serde(rename = "$type")]
35 pub r#type: String,
36
37 /// The blob content of the attachment
38 pub content: BlobRecord,
39}
40
41/// A blog post record from the ATProtocol lexicon.
42#[derive(Debug, Clone, Deserialize)]
43pub struct PostRecord {
44 /// The record type
45 #[serde(rename = "$type")]
46 pub r#type: String,
47
48 /// Title of the blog post
49 pub title: String,
50 /// Main content of the blog post
51 pub content: BlobRecord,
52
53 /// Publication timestamp
54 #[serde(rename = "publishedAt")]
55 pub published_at: DateTime<Utc>,
56
57 /// List of attachments to the post
58 #[serde(default = "empty_attachments")]
59 pub attachments: Vec<PostAttachment>,
60
61 /// Languages used in the post
62 pub langs: Vec<String>,
63}
64
65fn empty_attachments() -> Vec<PostAttachment> {
66 Vec::new()
67}