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

Method render

atomic-cli/src/commands/memory/list.rs:344–386  ·  view source on GitHub ↗

The shared render — the exact local body's table and JSON shapes, driven by the rows (computed in-process by the local body or reconstructed from the wire's per-entry classification).

(rows: &[Row], json: bool)

Source from the content-addressed store, hash-verified

342 /// driven by the rows (computed in-process by the local body or
343 /// reconstructed from the wire's per-entry classification).
344 pub(crate) fn render(rows: &[Row], json: bool) {
345 if json {
346 let json: Vec<serde_json::Value> = rows
347 .iter()
348 .map(|r| {
349 serde_json::json!({
350 "id": r.id,
351 "kind": r.kind,
352 "status": r.status,
353 "about": r.about,
354 "attested": r.attested.json(),
355 "verifies": r.verifies.json(),
356 })
357 })
358 .collect();
359 println!("{}", serde_json::to_string_pretty(&json).unwrap());
360 return;
361 }
362 if rows.is_empty() {
363 println!("No memories found.");
364 return;
365 }
366 // Fixed-width, left-aligned columns with a header row.
367 let id_w = col_width(rows.iter().map(|r| r.id.chars().count()), "id");
368 let kind_w = col_width(rows.iter().map(|r| r.kind.chars().count()), "kind");
369 let status_w = col_width(rows.iter().map(|r| r.status.chars().count()), "status");
370
371 println!(
372 " {:<id_w$} {:<kind_w$} {:<status_w$} {:>5} {:<8} verifies",
373 "id", "kind", "status", "about", "attested",
374 );
375 for r in rows {
376 println!(
377 " {:<id_w$} {:<kind_w$} {:<status_w$} {:>5} {:<8} {}",
378 r.id,
379 r.kind,
380 r.status,
381 r.about,
382 r.attested.table(),
383 r.verifies.table(),
384 );
385 }
386 }
387}
388
389/// One row reconstructed from the wire's per-entry classification — the

Callers

nothing calls this directly

Calls 5

col_widthFunction · 0.85
collectMethod · 0.45
iterMethod · 0.45
is_emptyMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected