Create a new vault entry. Computes the content hash automatically.
(
entry_type: VaultEntryType,
content: Vec<u8>,
frontmatter_json: String,
now: String,
)
| 99 | impl VaultEntry { |
| 100 | /// Create a new vault entry. Computes the content hash automatically. |
| 101 | pub fn new( |
| 102 | entry_type: VaultEntryType, |
| 103 | content: Vec<u8>, |
| 104 | frontmatter_json: String, |
| 105 | now: String, |
| 106 | ) -> Self { |
| 107 | let content_hash = blake3::hash(&content); |
| 108 | Self { |
| 109 | entry_type, |
| 110 | content_hash: *content_hash.as_bytes(), |
| 111 | content_bytes: content, |
| 112 | frontmatter_json, |
| 113 | created_at: now.clone(), |
| 114 | updated_at: now, |
| 115 | introduced_by: 0, |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | /// Size in bytes (content only, not metadata). |
| 120 | pub fn content_size(&self) -> usize { |