Overview
Outcome<S, M, F>
is an augmentation of the Result
type
found in the Rust standard library.
It is an enum with the variants
Success(S)
, representing success and containing a valueMistake(M)
, representing an optionally retryable error and containing a valueFailure(F)
, representing failure and containing a value.
Outcome
is an augmentation to Result
. It adds a third state to
the "success or failure" dichotomy that Result<T, E>
models.
This third state is that of a soft or retryable error. A retryable
error is one where an operation might not have succeeded, either due to
other operations (e.g., a disk read or write not completing),
misconfiguration (e.g., forgetting to set a specific flag before calling a
function), or busy resources (e.g., attempting to lock an audio, video, or
database resource).
use *;
;
let version = parse_version;
assert_eq!;
Usage
At this time, the name outcome
is already taken on crates.io. As
crates.io does not yet support namespaces or collections, we've had to
take a unique approach to still publish the crate. To do this, we've
generated a UUIDv5
string via python:
This should generate the string 46f94afc-026f-5511-9d7e-7d1fd495fb5c
.
Thus the dependency in your Cargo.toml
will look something like:
[]
= "*"
However, the exported library is still named outcome
, so importing it is
treated the same:
use *;
Users can also work around this by using the package
key in their
dependency declaration:
[]
= "*"
= "outcome-46f94afc-026f-5511-9d7e-7d1fd495fb5c"
Is this solution friendly to users? No, but neither is the lack of namespacing nor a squatting policy on crates.io. If/when this problem is resolved, this crate's documentation (and name!) will be changed and all versions will be yanked.