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