core/result library
Re-exports the Result<T> / Failure types from resilify.
token_keeper 1.1.0 unified its result type with the
resilify package so that callers can
share a single Result / Failure model across token management and the
rest of their networking stack.
Heads up —
dart:core.Errorcollision. The Error variant fromresilifyshadowsdart:core.Error. If you need both in the same file, hide one at the import site:import 'package:token_keeper/token_keeper.dart'; import 'dart:core' hide Error;
Classes
- CircuitBreaker
- Wraps an unreliable operation with the circuit-breaker resilience pattern: after failureThreshold consecutive failures the breaker "opens" and fast-fails calls for resetTimeout; one probe call is then admitted, and its outcome decides whether the breaker closes or reopens.
-
Error<
T> - The failed variant of a Result.
- Failure
- An immutable, structured description of why an operation failed.
-
Result<
T> -
A type-safe representation of an operation that either produced a value of
type
T(Success) or failed with a Failure (Error). -
ResultCache<
K, V> - An in-memory cache for Result values with optional TTL expiry.
-
ResultDeduplicator<
K, V> - Ensures only one Future<Result<V>> is in flight per key at any time.
- RetryHelper
- Static helpers for retrying Result-returning async operations.
-
Success<
T> - The successful variant of a Result.
Enums
- CircuitBreakerState
- State of a CircuitBreaker.
- FailureKind
- Categorical tag describing what kind of thing went wrong, independent of any HTTP status code or human-readable message.
- FailureType
- Structural category of a Failure.
Extensions
-
FlattenResultX
on Result<
Result< T> > - Collapses a nested Result into a single layer. If the outer is an Error, it is returned unchanged; otherwise the inner Result is returned.
-
FutureResultX
on Future<
Result< T> > -
Async helpers on
Future<Result<T>>. -
FutureToResultX
on Future<
T> -
Bridges a regular
Future<T>(which signals failure by throwing) into aFuture<Result<T>>without writingResult.tryRunAsync(() => future)at every call site. -
ResultAsyncX
on Result<
T> - Async transformations applied directly to a Result (not a future).
-
ResultListX
on Result<
List< T> > - Extensions that operate on the elements inside a successful list result.
-
ResultX
on Result<
T> - Synchronous helpers on Result.
-
StreamResultX
on Stream<
Result< T> > - Extensions for working with streams of Result values without unwrapping each event manually.
Typedefs
- LogCallback = void Function(String line)
- Sink for log lines emitted by resilify interceptors and handlers.
Exceptions / Errors
- ResultUnwrapException
- Thrown by ResultX.getOrThrow when called on an Error.