import { Buffer } from 'buffer';
import { MaybePromise } from '@httptoolkit/util';
import { CompletedBody, Headers } from "../types";
import { Replace } from "../util/type-utils";
export type SerializedBody = string | {
    encoded: string;
    decoded: string;
    decodingError: undefined;
} | {
    encoded: string;
    decoded: undefined;
    decodingError: undefined;
} | {
    encoded: string;
    decodingError: string;
    decoded: undefined;
};
export declare function withSerializedBodyReader<T extends {
    headers: Headers;
    body: CompletedBody;
}>(input: T, bodySerializer: BodySerializer): Promise<Replace<T, {
    body: SerializedBody;
}>>;
export type BodySerializer = (body: CompletedBody, headers: Headers) => MaybePromise<SerializedBody>;
export declare function withDeserializedBodyReader<T extends {
    headers: Headers;
    body: CompletedBody;
}>(input: Replace<T, {
    body: SerializedBody;
}>): T;
export declare function deserializeBodyReader(encodedBodyString: string, decodedBodyString: string | undefined, decodingError: string | undefined, headers: Headers): CompletedBody;
/**
 * Serialize a callback result (callback handlers, BeforeRequest/Response etc)
 * to transform all the many possible buffer formats into either base64-encoded
 * buffer data, or undefined.
 */
export declare function withSerializedCallbackBuffers<T extends {
    body?: CompletedBody | Buffer | Uint8Array | ArrayBuffer | string;
    rawBody?: Buffer | Uint8Array;
}>(input: T): Replace<T, {
    body: string | undefined;
}>;
export type WithSerializedCallbackBuffers<T extends {
    body?: any;
}> = Replace<T, {
    body?: string;
    rawBody?: string;
}>;
/**
 * Deserialize a callback result (callback handlers, BeforeRequest/Response etc)
 * to build buffer data (or undefined) from the base64-serialized data
 * produced by withSerializedCallbackBuffers
 */
export declare function withDeserializedCallbackBuffers<T extends {
    body?: Buffer | Uint8Array | string;
    rawBody?: Buffer | Uint8Array;
}>(input: Replace<T, {
    body?: string;
    rawBody?: string;
}>): T;
//# sourceMappingURL=body-serialization.d.ts.map