/**
 * Marks encoded worker message fields that should move through `postMessage` as
 * transfer-list entries.
 *
 * Worker messages still pass through schema encoding and structured clone, but
 * schemas wrapped with `schema` can also report backing resources such as
 * `ArrayBuffer`, `ImageData.data.buffer`, or `MessagePort` to a `Collector`.
 * Worker platforms then pass the collected values as the transfer list for the
 * same `postMessage` call, avoiding copies for large payloads and ports.
 *
 * **Mental model**
 *
 * A `Collector` is an optional context service. During encoding, `getterAddAll`
 * and `schema` add transferable values when a collector is present and leave the
 * encoded value unchanged. The built-in `Uint8Array`, `ImageData`, and
 * `MessagePort` schemas are convenience wrappers around the same behavior.
 *
 * **Common tasks**
 *
 * Wrap a worker message field with `schema` when the transferable is nested or
 * derived from the encoded value. Provide a fresh collector around each message
 * encode, read or clear it after encoding, and pass the resulting list to the
 * worker transport.
 *
 * **Gotchas**
 *
 * Transfer annotations do not make unsupported values structured-cloneable.
 * Ownership moves to the receiver after `postMessage`, so buffers are detached
 * from the sender. For typed array views, collecting `view.buffer` transfers the
 * whole backing buffer, including bytes used by other views.
 *
 * @since 4.0.0
 */
import * as Context from "../../Context.ts";
import * as Effect from "../../Effect.ts";
import * as Schema from "../../Schema.ts";
import * as Getter from "../../SchemaGetter.ts";
declare const Collector_base: Context.ServiceClass<Collector, "effect/workers/Transferable/Collector", {
    readonly addAll: (_: Iterable<globalThis.Transferable>) => Effect.Effect<void>;
    readonly addAllUnsafe: (_: Iterable<globalThis.Transferable>) => void;
    readonly read: Effect.Effect<Array<globalThis.Transferable>>;
    readonly readUnsafe: () => Array<globalThis.Transferable>;
    readonly clearUnsafe: () => Array<globalThis.Transferable>;
    readonly clear: Effect.Effect<Array<globalThis.Transferable>>;
}>;
/**
 * Service for collecting `Transferable` objects while encoding worker messages
 * so they can be passed to `postMessage` transfer lists.
 *
 * @category models
 * @since 4.0.0
 */
export declare class Collector extends Collector_base {
}
/**
 * Creates a mutable `Collector` service directly, exposing unsafe synchronous
 * methods for reading, adding, and clearing collected transferables.
 *
 * @category constructors
 * @since 4.0.0
 */
export declare const makeCollectorUnsafe: () => Collector["Service"];
/**
 * Effect that creates a fresh `Collector` service for accumulating
 * transferables.
 *
 * @category constructors
 * @since 4.0.0
 */
export declare const makeCollector: Effect.Effect<Collector["Service"]>;
/**
 * Adds transferables to the current `Collector` when one is present in the
 * context, and does nothing otherwise.
 *
 * @category accessors
 * @since 4.0.0
 */
export declare const addAll: (tranferables: Iterable<globalThis.Transferable>) => Effect.Effect<void>;
/**
 * Creates a schema getter that records transferables derived from a value in
 * the current `Collector` while passing the value through unchanged.
 *
 * @category getters
 * @since 4.0.0
 */
export declare const getterAddAll: <A>(f: (_: A) => Iterable<globalThis.Transferable>) => Getter.Getter<A, A>;
/**
 * Schema wrapper whose encode path can record transferables with a `Collector`
 * while preserving the wrapped schema's decoded type.
 *
 * @category schemas
 * @since 4.0.0
 */
export interface Transferable<S extends Schema.Top> extends Schema.decodeTo<Schema.toType<S["Rebuild"]>, S["Rebuild"]> {
}
/**
 * Wraps a schema so encoding records transferables selected from the encoded
 * value, enabling worker messages to populate a `postMessage` transfer list.
 *
 * @category schemas
 * @since 4.0.0
 */
export declare const schema: {
    /**
     * Wraps a schema so encoding records transferables selected from the encoded
     * value, enabling worker messages to populate a `postMessage` transfer list.
     *
     * @category schemas
     * @since 4.0.0
     */
    <S extends Schema.Top>(f: (_: S["Encoded"]) => Iterable<globalThis.Transferable>): (self: S) => Transferable<S>;
    /**
     * Wraps a schema so encoding records transferables selected from the encoded
     * value, enabling worker messages to populate a `postMessage` transfer list.
     *
     * @category schemas
     * @since 4.0.0
     */
    <S extends Schema.Top>(self: S, f: (_: S["Encoded"]) => Iterable<globalThis.Transferable>): Transferable<S>;
};
/**
 * Schema for transferring `ImageData` values with their pixel data buffer.
 *
 * @category schemas
 * @since 4.0.0
 */
export declare const ImageData: Transferable<Schema.declare<ImageData>>;
/**
 * Schema for transferring `MessagePort` values as transferable objects.
 *
 * @category schemas
 * @since 4.0.0
 */
export declare const MessagePort: Transferable<Schema.declare<MessagePort>>;
/**
 * Schema for transferring `Uint8Array` values with their backing buffer.
 *
 * @category schemas
 * @since 4.0.0
 */
export declare const Uint8Array: Transferable<Schema.instanceOf<globalThis.Uint8Array<ArrayBuffer>>>;
export {};
//# sourceMappingURL=Transferable.d.ts.map