Skip to content

Collapse discovery TXT into one seam in usbip-core — Rust + Kotlin reuse #30

Description

@stanvx

Parent

Architecture review (2026-06-21). Slice 4 of 6 from the deepening series. Documented at server/usbip-server/src/discovery.rs, client/usbip-client/src/discovery.rs, and server/usbip-server/src/api.rs:100-103.

What to build

The wire format for mDNS TXT records is encoded in server/usbip-server/src/discovery.rs (encode_devices_txt + 3 tests) and decoded in client/usbip-client/src/discovery.rs (decode_devices_txt + 0 tests). Two implementations of one wire format with no shared contract. The future Kotlin client will be the third.

Lift both into a new usbip_core::discovery_txt module. Server encodes via that module. Client decodes via that module. Treat the wire format as a contract with golden fixtures. Add a #[doc(hidden)] const TXT_FORMAT_V1: &[u8] = ... so the format version is visible at the call site.

This is the smallest, highest-leverage contract change. Once shared, the Kotlin client cannot drift from the Rust encoder.

Acceptance criteria

  • New module usbip-core/src/discovery_txt.rs with pub fn encode(devices: &[DeviceDescriptor]) -> String and pub fn decode(txt: &str) -> Result<Vec<DeviceDescriptor>, DiscoveryTxtError>
  • Server's encode_devices_txt becomes a thin re-export or is deleted
  • Client's decode_devices_txt becomes a thin re-export or is deleted
  • At least 6 round-trip tests cover: empty device list, single device, multiple devices, special characters in product strings, malformed input rejection, format version mismatch
  • tests/fixtures/discovery_txt/ contains a golden TXT file and the test asserts byte-for-byte encoding stability
  • Module doc-comment records the wire format with a BNF-style grammar
  • cargo test --workspace --release passes; cargo clippy --workspace -- -D warnings clean

Blocked by

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestready-for-agentTriage complete; ready for an agent to implement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions