jeremyletang/rust-sndfile — pull request #1 by adevore (2014-09-18 07:44:36+00:00)
Title: Change from error codes to Result-based errors

The current API directly exposes libsndfile's error codes. This patch encapsulates the libsndfile's SF_ERR C enum within a new Rust enum, `SndFileError`, and a type alias, `type SndFileResult = Result`. Operations that previously returned an error now return a SndFileError or SndFileResult.

Advantages:

* Users are warned if they do not handle the Result.
* All of the machinery surrounding Result become available (try!, Result's methods)
* NoError is no longer part of the Error enum, which was unintuitive.

`string_error` and `error_number` have been removed in favor of using SndFileError::desc() and SndFile::error(). For example:

```rust
fn print_error(sf: SndFile) {
match sf.error() {
Some(err) => println!("Error: {}", err.desc()),
None => println!("No errors occurred")
}
}
```