rust cli: Implement mcap get commands - #1622
Conversation
Co-authored-by: Adrian Macneil <adrian@foxglove.dev>
Co-authored-by: Adrian Macneil <adrian@foxglove.dev>
Co-authored-by: Adrian Macneil <adrian@foxglove.dev>
mcap get attachment and metadata commands
Co-authored-by: Adrian Macneil <adrian@foxglove.dev>
Co-authored-by: Adrian Macneil <adrian@foxglove.dev>
Co-authored-by: Adrian Macneil <adrian@foxglove.dev>
Co-authored-by: Adrian Macneil <adrian@foxglove.dev>
Co-authored-by: Adrian Macneil <adrian@foxglove.dev>
Co-authored-by: Adrian Macneil <adrian@foxglove.dev>
There was a problem hiding this comment.
All prior threads resolved — minimized old review-level comments.
The implementation looks solid. Attachment selection logic is clean, metadata merge semantics match Go, and test coverage hits the important cases. Two minor items inline (neither blocking): the intentional offset-validation divergence from Go, and a missing metadata wiring test case.
One thing I verified: the Rust merged_metadata_for_name explicitly sorts by offset before merging, while Go iterates in MetadataIndexes insertion order. In practice these should match, but the Rust version is more robust if index order ever diverges from file order.
| 1 => { | ||
| let first_match = matches[0]; | ||
| if let Some(offset) = offset { | ||
| if first_match.offset != offset { | ||
| anyhow::bail!("failed to find attachment {name} at offset {offset}"); | ||
| } | ||
| } | ||
| Ok(first_match) |
There was a problem hiding this comment.
Nit: the Rust CLI now validates --offset even when there's only one matching attachment (lines 50-53), which is stricter than the Go CLI (go/cli/mcap/cmd/attachment.go:97-100 — Go silently returns the single match regardless of --offset). I think the Rust behavior is better, but worth noting the divergence. If you want parity, the Go side could get the same fix in a follow-up.
There was a problem hiding this comment.
Rust behavior is better
Co-authored-by: Adrian Macneil <adrian@foxglove.dev>
mcap get attachment and metadata commandsmcap get commands
Summary
mcap get attachmentinrust/mcap_cliwith--name, optional--offset, and optional--outputmcap get metadatainrust/mcap_cliwith--nameusing namespace-level last-write-wins semantics (highest-offset record for that name)--offsetis enforced even when only one same-name attachment existsTesting
cd rust && cargo test -p mcap_clicd rust && cargo clippy -p mcap_cli --all-targets -- --no-deps -D warnings