Skip to content

Change all bool-returns to Results

Rather than dealing with bools, this changes every function that returned a bool to return Result<(), Error>. As far as I can tell speech-dispatcher consistently uses 0 == success, -1 == failure, so converting 0 -> Ok works.

Additionally:

  • Make open2 fallible too
  • Use a Result the entire time in open and open2, instead of going from Option to Result
  • Specify c_int instead of i32 since apparently the size "may differ on some esoteric systems"; I suspect it won't compile on whatever those are but might as well improve the situation
  • Avoid a maybe-possible panic in get_voice_type. Probably can't happen but I'm not 100% certain, so I made it fallible
  • Add a missing null check to get_language

This also changes SpeechDispatcherError to just Error, which I think is more common naming and makes formatting a bit better. This is a separate commit so it's easy to undo if you'd rather not change its name. (edit: I forgot type aliases exist until taking a bite of my lunch. Will try one later today)

This refactor seems to work but I haven't done any kind of exhaustive testing.

Edited by Malloc Voidstar

Merge request reports