Expand description
§pw_status
Rust error types using error codes compatible with Pigweed’s
pw_status. In order to keep the interface
idiomatic for Rust, PW_STATUS_OK
is omitted from the Error enum and a
StatusCode
trait is provided to turn a Result
into a canonical
status code.
For an in depth explanation of the values of the Error
enum, see
the Pigweed status codes documentation.
§Example
use pw_status::{Error, Result};
fn div(numerator: u32, denominator: u32) -> Result<u32> {
if denominator == 0 {
Err(Error::FailedPrecondition)
} else {
Ok(numerator / denominator)
}
}
assert_eq!(div(4, 2), Ok(2));
assert_eq!(div(4, 0), Err(Error::FailedPrecondition));
Enums§
- Error type compatible with Pigweed’s pw_status.
Constants§
- Status code for no error.
Traits§
- Convert a Result into an status code.