fumus.utils.result ================== .. py:module:: fumus.utils.result Classes ------- .. autoapisummary:: fumus.utils.result.Result Module Contents --------------- .. py:class:: Result(value=None, error=None) .. py:attribute:: __slots__ :value: ('value', 'error') .. py:attribute:: value :value: None .. py:attribute:: error :value: None .. py:property:: is_successful Returns bool whether the Result is successful and an error is not present .. py:method:: success(value) :classmethod: Creates Result describing given value .. py:method:: failure(error) :classmethod: Creates Result describing given error .. py:method:: map_success(mapper) 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) .. py:method:: map_failure(mapper) 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 .. py:method:: map(on_success, on_failure) Combines map_success() and map_failure() .. py:method:: if_success(consumer) Performs given action with the value if the Result is successful .. py:method:: if_failure(consumer) Performs given action with the error if the Result is not successful .. py:method:: handle(on_success, on_failure) Combines if_success() and if_failure() .. py:method:: or_else(other) Returns the value if successful, or a provided argument otherwise .. py:method:: or_else_get(supplier) Returns the value if present, or calls a 'supplier' function otherwise .. py:method:: or_else_raise(supplier=None) Returns the value if successful, otherwise throws an exception produced by the exception supplying function (if such is provided by the user) or re-raises original Exception .. py:method:: __str__() .. py:method:: __eq__(other) .. py:method:: __hash__() .. py:method:: _map_result(mapper, arg) :staticmethod: