Skip to content

libtopo: examples and README polish#6

Open
smklein wants to merge 1 commit into
mainfrom
libtopo-polish
Open

libtopo: examples and README polish#6
smklein wants to merge 1 commit into
mainfrom
libtopo-polish

Conversation

@smklein
Copy link
Copy Markdown
Collaborator

@smklein smklein commented May 12, 2026

Summary

Fourth and final PR in the libtopo wrapper stack. Adds two runnable examples and updates the READMEs to reflect the now-functional API. Stacked on libtopo-walker-fmri-props.

Examples

  • libtopo/examples/list_topology.rs — opens a handle, takes a snapshot, walks a topology scheme, prints each node's name[instance], FMRI, and label. Defaults to hc; accepts an optional scheme name as the first argv:

    pfexec cargo run --example list_topology
    pfexec cargo run --example list_topology -- cpu
    pfexec cargo run --example list_topology -- pcie
    

    Exercises TopoHdl::open + snapshot + Snapshot::walk + node.resource() + hdl.fmri_to_string + node.label().

  • libtopo/examples/fmri_resolve.rs — takes an FMRI string on argv, parses it, then prints present / replaced / unusable. Exercises fmri_parse + fmri_to_string + fmri_present + fmri_replaced + fmri_unusable.

Verified end-to-end on a Helios 3 host across hc, cpu, pcie, and an unknown-scheme rejection.

READMEs

  • libtopo/README.md — replace cargo-new placeholder with idiomatic usage block, notes on pfexec, examples, and CI behavior. Fixes typo "this create provids" → "this crate provides".
  • README.md (root) — expand from one-liner to mirror fmd-adm / illumos-nvpair structure: intro, crates breakdown, usage, privileges, testing.

No code changes in the wrapper crate; only examples and docs.

Test plan

cargo fmt --check, cargo build --all-targets, cargo clippy --all-targets -- -D warnings, pfexec cargo test all green

@smklein smklein marked this pull request as draft May 12, 2026 00:49
@smklein smklein force-pushed the libtopo-walker-fmri-props branch from 3724506 to 28b13c4 Compare May 12, 2026 01:20
@smklein smklein force-pushed the libtopo-walker-fmri-props branch from 28b13c4 to 6f9d60a Compare May 12, 2026 01:39
@smklein smklein force-pushed the libtopo-walker-fmri-props branch 2 times, most recently from 31a5cae to f5e9e7a Compare May 12, 2026 20:06
@smklein smklein force-pushed the libtopo-polish branch 2 times, most recently from e02a2ae to bd84627 Compare May 12, 2026 22:19
@smklein smklein force-pushed the libtopo-walker-fmri-props branch 2 times, most recently from 3acea59 to ee635cd Compare May 12, 2026 22:24
@smklein smklein force-pushed the libtopo-walker-fmri-props branch from ee635cd to d790388 Compare May 12, 2026 22:29
@smklein smklein force-pushed the libtopo-polish branch 2 times, most recently from bf2ebf1 to 6fa8597 Compare May 12, 2026 22:58
@smklein smklein force-pushed the libtopo-walker-fmri-props branch from d790388 to 1dd188a Compare May 12, 2026 22:58
Two runnable examples plus README updates to reflect the now-functional
API.

Examples (libtopo/examples/):

- list_topology.rs: opens a handle, takes a snapshot, walks a topology
  scheme, and prints each node's name[instance], FMRI, and label.
  Defaults to the `hc` scheme; accepts an optional scheme name as the
  first positional argument to walk a different one. Pass `-v` /
  `--verbose` (anywhere in argv) to also dump every property group and
  property under each node, e.g.

      pfexec cargo run --example list_topology -- cpu
      pfexec cargo run --example list_topology -- pcie -v

  Exercises TopoHdl::open + snapshot + Snapshot::walk + node.resource()
  + hdl.fmri_to_string + node.label() + node.property_groups() (in
  verbose mode), with a per-PropValue printer.

- fmri_resolve.rs: takes an FMRI string on argv, parses it via
  fmri_parse, then prints present / replaced / unusable. Exercises
  TopoHdl::fmri_parse + fmri_to_string + fmri_present + fmri_replaced
  + fmri_unusable.

Both examples were verified end-to-end on a Helios 3 host with various
scheme arguments and the verbose flag.

READMEs:

- libtopo/README.md: replace cargo-new placeholder with an idiomatic
  usage block (TopoHdl::open + snapshot + walk + resource +
  fmri_to_string) and notes on pfexec, examples, and CI behavior.
  Fixes typo "this create provids" -> "this crate provides".

- README.md (root): expand from a one-liner to mirror fmd-adm /
  illumos-nvpair structure (intro, crates breakdown, usage example,
  privileges, testing).

No code changes in the wrapper crate; only examples and docs.

Quality gate on Helios 3: cargo fmt --check, cargo build --all-targets,
cargo clippy --all-targets -- -D warnings, pfexec cargo test all green.
Example runs verified for default (hc), cpu, pcie, verbose mode, and
an unknown-scheme rejection path.
@smklein smklein force-pushed the libtopo-walker-fmri-props branch from 1dd188a to 62e371a Compare May 12, 2026 23:06
@smklein smklein marked this pull request as ready for review May 12, 2026 23:08
Base automatically changed from libtopo-walker-fmri-props to main May 12, 2026 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant