import { AsyncOption } from "./async_option"; import type { Result, ResultImpl, ResultMatch, ResultMatchAsync } from "./result"; /** * A promise that resolves to a `Result`. * * This class is useful for chaining multiple asynchronous operations that return a `Result`. */ export declare class AsyncResult implements PromiseLike> { readonly promise: Promise> | PromiseLike> | AsyncResult; constructor(promise: Promise> | PromiseLike> | AsyncResult); [Symbol.iterator](): Iterator, T, any>; then(successCallback?: (res: Result) => A | PromiseLike, failureCallback?: (reason: unknown) => B | PromiseLike): PromiseLike; catch(rejectionCallback?: (reason: unknown) => B | PromiseLike): PromiseLike; finally(callback: () => void): PromiseLike>; /** * Async version of `Result#match`. */ match(matcher: ResultMatch): Promise; matchAsync(matcher: ResultMatchAsync): Promise; value(): Promise; error(): Promise; /** * Async version of `Result#ok`. */ ok(): AsyncOption; /** * Async version of `Result#err`. */ err(): AsyncOption; /** * Async version of `Result#and`. */ and(other: AsyncResult): AsyncResult; /** * Async version of `Result#andThen`. */ andThen(f: (value: T) => Result): AsyncResult; /** * Async version of `Result#andThenAsync`. */ andThenAsync(f: (value: T) => Promise>): AsyncResult; /** * Async version of `Result#expect`. */ expect(message: string): Promise; /** * Async version of `Result#expectErr`. */ expectErr(message: string): Promise; /** * Async version of `Result#flatten`. */ flatten(this: AsyncResult, E>): AsyncResult; /** * Async version of `Result#inspect`. */ inspect(f: (value: T) => void): AsyncResult; /** * Async version of `Result#inspectAsync`. */ inspectAsync(f: (value: T) => Promise): AsyncResult; /** * Async version of `Result#inspectErr`. */ inspectErr(f: (error: E) => void): AsyncResult; /** * Async version of `Result#inspectErrAsync`. */ inspectErrAsync(f: (error: E) => Promise): AsyncResult; /** * Async version of `Result#map`. */ map(f: (value: T) => U): AsyncResult; /** * Async version of `Result#mapAsync`. */ mapAsync(f: (value: T) => Promise): AsyncResult; /** * Async version of `Result#mapErr`. */ mapErr(f: (error: E) => F): AsyncResult; /** * Async version of `Result#mapErrAsync`. */ mapErrAsync(f: (error: E) => Promise): AsyncResult; /** * Async version of `Result#mapOr`. */ mapOr(defaultValue: A, f: (value: T) => B): Promise; /** * Async version of `Result#mapOrElse`. */ mapOrElse(defaultValue: (error: E) => A, f: (value: T) => B): Promise; /** * Async version of `Result#or`. */ or(other: AsyncResult): AsyncResult; /** * Async version of `Result#orElse`. */ orElse(f: (error: E) => Result): AsyncResult; /** * Async version of `Result#orElseAsync`. */ orElseAsync(f: (error: E) => Promise>): AsyncResult; /** * Async version of `Result#unwrap`. */ unwrap(): Promise; /** * Async version of `Result#unwrapErr`. */ unwrapErr(): Promise; /** * Async version of `Result#unwrapOr`. */ unwrapOr(defaultValue: U): Promise; /** * Async version of `Result#unwrapOrElse`. */ unwrapOrElse(defaultValue: (error: E) => U): Promise; }