Skip to content

Conversation

@nagisa
Copy link
Contributor

@nagisa nagisa commented Apr 19, 2025

I find it quite annoying to keep building the home descriptions and one
of the more annoying things I find is describing properties. This change
improves the situation slightly by making it quite a bit more
straightforward to describe common integer, float and boolean formats.
In particular now instead of having to write out the entire
HomePropertyFormat::SomeType(SomeType { ... }), IntegerRange, FloatRange,
BooleanFormat etc can be passed in as an argument directly. For
integers and floats a further ergonomics are achieved by allowing another
common case (range without step) to be provided by using Rust's
built-in ranges.

For color format it might make sense to explore making it a bitfield
rather than a vector of enums. Among other things it would enforce that
the same colour does not appear twice. But even if that's done in the
future these From implementations would still be implementable just
fine, so they seemed fine to add.

The only caveat is that this likely has a negative impact on diagnostics.

nagisa added 2 commits April 19, 2025 15:35
This is useful when HomieID is used as a clap argument (clap is able to
handle `from_str` arguments ~transparently) which is possibly a common
use-case to allow user-configurable device IDs.
I find it quite annoying to keep building the home descriptions and one
of the more annoying things I find is describing properties. This change
improves the situation slightly by making it quite a bit more
straightforward to describe common integer, float and boolean formats.
In particular now instead of having to write out the entire
`HomePropertyFormat::SomeType`, `IntegerRange`, `FloatRange`,
`BooleanFormat` etc can be passed in as an argument directly. For
integers and floats a furher ergonomics are achieved by allowing an even
more common case (range without step) to be provided by using Rust's
built-in ranges.

For color format it might make sense to explore making it a bitfield
rather than a vector of enums. Among other things it would enforce that
the same colour does not appear twice. But even if that's done in the
future these From implementations would still be implementable just
fine, so they seemed fine to add.
@schaze schaze merged commit 9934734 into schaze:main May 29, 2025
2 checks passed
@nagisa nagisa deleted the property-format-conversions branch June 9, 2025 11:07
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.

2 participants