Create a new vault entry. Computes the content hash automatically.
(
entry_type: VaultEntryType,
content: Vec<u8>,
frontmatter_json: String,
now: String,
)
| 124 | impl VaultEntry { |
| 125 | /// Create a new vault entry. Computes the content hash automatically. |
| 126 | pub fn new( |
| 127 | entry_type: VaultEntryType, |
| 128 | content: Vec<u8>, |
| 129 | frontmatter_json: String, |
| 130 | now: String, |
| 131 | ) -> Self { |
| 132 | let content_hash = blake3::hash(&content); |
| 133 | Self { |
| 134 | entry_type, |
| 135 | content_hash: *content_hash.as_bytes(), |
| 136 | content_bytes: content, |
| 137 | frontmatter_json, |
| 138 | created_at: now.clone(), |
| 139 | updated_at: now, |
| 140 | introduced_by: 0, |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | /// Size in bytes (content only, not metadata). |
| 145 | pub fn content_size(&self) -> usize { |