Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use Display, not custom to_string, for Mood #49

Closed
warner opened this issue May 26, 2018 · 1 comment · Fixed by #74
Closed

use Display, not custom to_string, for Mood #49

warner opened this issue May 26, 2018 · 1 comment · Fixed by #74

Comments

@warner
Copy link
Collaborator

warner commented May 26, 2018

@copyninja mentioned (in warner@46d31b8#commitcomment-29139497) that to_string should be part of the standard Display trait, but I used it as a standalone method on the Mood struct. I'm up for making this Display, but the specific strings used there are part of the wire protocol, so they're fixed and should not be changed in the future (e.g. as part of i18n language-specific translations). So we need some comments to that effect, and some unit tests that ensure the strings remain fixed.

@warner
Copy link
Collaborator Author

warner commented May 27, 2018

I implemented Display for the newtypes from #32, and ran into just this sort of problem:

  • Mailboxes were stringified as Mailbox(abc123) instead of just abc123, which made its way into the OPEN and CLOSE messages we sent to the server, which confused things
  • the Moods are named Happy and Scared and Error, but in the CLOSE message they're spelled happy and scary and errory, which would break the server statistics

I added unit tests on the message serialization code to make sure these are getting stringified properly.

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 a pull request may close this issue.

1 participant