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

Function tree_entry_proto

libatomic/src/daemon/sandbox_wire.rs:90–103  ·  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

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

Callers 1

materializeMethod · 0.85

Calls 1

hash_protoFunction · 0.70

Tested by

no test coverage detected