import { type OplogIndex, type PersistenceLevel, type RetryPolicy } from "./hostapi";
/**
 * PersistenceLevelGuard is a guard type that sets the persistence level for the oplog.
 * You must call drop on the guard once you are finished using it.
 */
export declare class PersistenceLevelGuard {
    private originalLevel;
    constructor(originalLevel: PersistenceLevel);
    drop(): void;
}
/**
 * Sets the persistence level for the oplog and returns a guard.
 * You must call drop on the guard once you are finished using it.
 * @param level - The persistence level to set.
 * @returns A PersistenceLevelGuard instance.
 */
export declare function usePersistenceLevel(level: PersistenceLevel): PersistenceLevelGuard;
/**
 * Executes a function with a specific persistence level for the oplog.
 * @param level - The persistence level to set.
 * @param f - The function to execute.
 * @returns The result of the executed function.
 */
export declare function withPersistenceLevel<R>(level: PersistenceLevel, f: () => R): R;
/**
 * IdempotenceModeGuard is a guard type that sets the idempotence mode.
 * You must call drop on the guard once you are finished using it.
 */
export declare class IdempotenceModeGuard {
    private original;
    constructor(original: boolean);
    drop(): void;
}
/**
 * Sets the idempotence mode and returns a guard.
 * You must call drop on the guard once you are finished using it.
 * @param mode - The idempotence mode to set.
 * @returns An IdempotenceModeGuard instance.
 */
export declare function useIdempotenceMode(mode: boolean): IdempotenceModeGuard;
/**
 * Executes a function with a specific idempotence mode.
 * @param mode - The idempotence mode to set.
 * @param f - The function to execute.
 * @returns The result of the executed function.
 */
export declare function withIdempotenceMode<R>(mode: boolean, f: () => R): R;
/**
 * RetryPolicyGuard is a guard type that sets the retry policy.
 * You must call drop on the guard once you are finished using it.
 */
export declare class RetryPolicyGuard {
    private original;
    constructor(original: RetryPolicy);
    drop(): void;
}
/**
 * Sets the retry policy and returns a guard.
 * You must call drop on the guard once you are finished using it.
 * @param policy - The retry policy to set.
 * @returns A RetryPolicyGuard instance.
 */
export declare function useRetryPolicy(policy: RetryPolicy): RetryPolicyGuard;
/**
 * Executes a function with a specific retry policy.
 * @param policy - The retry policy to set.
 * @param f - The function to execute.
 * @returns The result of the executed function.
 */
export declare function withRetryPolicy<R>(policy: RetryPolicy, f: () => R): R;
/**
 * AtomicOperationGuard is a guard type that marks the beginning and end of an atomic operation.
 * You must call drop on the guard once you are finished using it.
 */
export declare class AtomicOperationGuard {
    private begin;
    constructor(begin: OplogIndex);
    drop(): void;
}
/**
 * Marks the beginning of an atomic operation and returns a guard.
 * You must call drop on the guard once you are finished using it.
 * @returns An AtomicOperationGuard instance.
 */
export declare function markAtomicOperation(): AtomicOperationGuard;
/**
 * Executes a function atomically.
 * @param f - The function to execute atomically.
 * @returns The result of the executed function.
 */
export declare function atomically<T>(f: () => T): T;
/**
 * Executes a function and automatically drops the provided resources after execution.
 * @param resources - An array of resources to be dropped after execution.
 * @param fn - The function to execute.
 * @returns The result of the executed function.
 */
export declare function executeWithDrop<Resource extends {
    drop: () => void;
}, R>(resources: [Resource], fn: () => R): R;
/**
 * Drops all the provided resources and collects any errors that occur during the process.
 * @param resources - An array of resources to be dropped.
 * @throws DropError if any errors occur during the dropping process.
 */
export declare function dropAll<Resource extends {
    drop: () => void;
}>(throwOnError: boolean, resources: [Resource]): void;
