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

Method from_wire

atomic-cli/src/commands/view/list.rs:205–234  ·  view source on GitHub ↗

Build from the wire `ViewInfo` the daemon returns over RPC. Carries the same metadata as the local listing, so both paths render identically.

(view: &atomic_client::proto::ViewInfo)

Source from the content-addressed store, hash-verified

203 /// the same metadata as the local listing, so both paths render
204 /// identically.
205 pub(crate) fn from_wire(view: &atomic_client::proto::ViewInfo) -> Self {
206 let kind = match atomic_client::proto::ViewScope::try_from(view.scope) {
207 Ok(atomic_client::proto::ViewScope::Draft) => "draft",
208 _ => "shared",
209 };
210 let state_short = view
211 .head
212 .as_ref()
213 .and_then(|hash| hash.value.clone().try_into().ok())
214 .map(|bytes: [u8; 32]| {
215 let full = atomic_core::types::Merkle(bytes).to_base32();
216 if full.len() > 12 {
217 full[..12].to_string()
218 } else {
219 full
220 }
221 })
222 .unwrap_or_else(|| "-".to_string());
223 ViewEntry {
224 name: view.name.clone(),
225 parent: view.parent.clone(),
226 own_change_count: view.own_change_count.unwrap_or(view.change_count),
227 change_count: view.change_count,
228 inherited_change_count: view.inherited_change_count.unwrap_or(0),
229 kind,
230 state_short,
231 is_current: view.current,
232 has_info: true,
233 }
234 }
235}
236
237/// Decide which views are shown.

Callers

nothing calls this directly

Calls 6

MerkleClass · 0.85
as_refMethod · 0.80
okMethod · 0.45
cloneMethod · 0.45
to_base32Method · 0.45
lenMethod · 0.45

Tested by

no test coverage detected