Skip to content

Add try_value methods to reply structs - #295

Open
mina86 wants to merge 1 commit into
rust-x-bindings:mainfrom
mina86:b
Open

Add try_value methods to reply structs#295
mina86 wants to merge 1 commit into
rust-x-bindings:mainfrom
mina86:b

Conversation

@mina86

@mina86 mina86 commented May 1, 2026

Copy link
Copy Markdown

The value method of reply structs (such as GetPropertyReply) panic if the format of the reply does not match the format of the property. This forces user to check the format which is then later checked in the method duplicating the condition.

Since the method already knows the correct format, a more user-friendly and less error-prone approach is for the method to perform the check and return an error-condition if it fails. This is what try_value method does.

The `value` method of reply structs (such as `GetPropertyReply`) panic
if the format of the reply does not match the format of the property.
This forces user to check the format which is then later checked in the
method duplicating the condition.

Since the method already knows the correct format, a more user-friendly
and less error-prone approach is for the method to perform the check and
return an error-condition if it fails.  This is what `try_value` method
does.
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