fumus.utils.result
Classes
Module Contents
- class fumus.utils.result.Result(value=None, error=None)[source]
- __slots__ = ('value', 'error')
- value = None
- error = None
- property is_successful
Returns bool whether the Result is successful and an error is not present
- map_success(mapper)[source]
If a value is present, apply the provided mapping function to it, and if the result is non-null, return an Optional describing the result. Otherwise return an empty Optional. (NB: if the provided mapper returns an Optional, the result isn’t wrapped-up in an additional one)
- map_failure(mapper)[source]
If an error is present, apply the provided mapping function to it, and if the result is non-null, return an Optional describing the result. Otherwise return an empty Optional
- or_else_get(supplier)[source]
Returns the value if present, or calls a ‘supplier’ function otherwise