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