MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / tree_entry_proto

Function tree_entry_proto

libatomic/src/daemon/sandbox_wire.rs:95–108  ·  view source on GitHub ↗

A rendered entry as a [`pb::TreeEntry`]: the content rides inline.

(entry: ViewEntry)

Source from the content-addressed store, hash-verified

93
94/// A rendered entry as a [`pb::TreeEntry`]: the content rides inline.
95pub 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
110pub fn tree_entry_kind(entry: &pb::TreeEntry) -> Result<ViewEntryKind, String> {
111 match pb::TreeEntryKind::try_from(entry.kind) {

Callers 1

materializeMethod · 0.85

Calls 1

hash_protoFunction · 0.70

Tested by

no test coverage detected