A rendered entry as a [`pb::TreeEntry`]: the content rides inline.
(entry: ViewEntry)
| 93 | |
| 94 | /// A rendered entry as a [`pb::TreeEntry`]: the content rides inline. |
| 95 | pub fn tree_entry_proto(entry: ViewEntry) -> pb::TreeEntry { |
| 96 | let kind = match entry.kind { |
| 97 | ViewEntryKind::File => pb::TreeEntryKind::File, |
| 98 | ViewEntryKind::Directory => pb::TreeEntryKind::Directory, |
| 99 | ViewEntryKind::Symlink => pb::TreeEntryKind::Symlink, |
| 100 | }; |
| 101 | pb::TreeEntry { |
| 102 | path: entry.path, |
| 103 | kind: kind as i32, |
| 104 | content: (entry.kind != ViewEntryKind::Directory).then(|| hash_proto(&entry.hash)), |
| 105 | inline: (entry.kind != ViewEntryKind::Directory).then_some(entry.content), |
| 106 | mode: Some(u32::from(entry.mode)), |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | pub fn tree_entry_kind(entry: &pb::TreeEntry) -> Result<ViewEntryKind, String> { |
| 111 | match pb::TreeEntryKind::try_from(entry.kind) { |
no test coverage detected