Skip to content

Improve no_std Display for DbError to include numeric data fields #92

@lxsaah

Description

@lxsaah

Difficulty: easy · Estimate: 2–3 hours

The no_std Display impl for DbError currently prints only the category code and a generic message ("Error 0x1002: Connection failed"). Most variants carry numeric data (size, lag_count, record_id, id, component, error_code) that's still available without std and is highly useful when debugging on an MCU where you can't pull in Strings.

Where to look

What to do

For each variant that carries no_std-available numeric fields, include them in the Display output:

  • BufferFull { size }"Error 0x2002: Buffer full ({size} items)"
  • BufferLagged { lag_count }"Error 0xA001: Buffer lagged ({lag_count} messages)"
  • InvalidRecordId { id } → include id
  • TypeMismatch { record_id } → include record_id
  • AmbiguousType { count } → include count
  • HardwareError { component, error_code } → include both
  • Internal { code } → include code
  • ResourceUnavailable { resource_type } → include resource_type

Keep output bounded: no allocations, use write! directly.

Done when

  • Every variant's no_std Display includes its no_std-available data
  • A new #[cfg(not(feature = "std"))] test exercises a few variants and asserts on substring content
  • cargo build --no-default-features still works

We'd love help with this — comment if you'd like to take it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions