/** * @since 1.0.0 */ import type * as Chunk from "@effect/data/Chunk"; import type * as Context from "@effect/data/Context"; import type * as Either from "@effect/data/Either"; import type { LazyArg } from "@effect/data/Function"; import type * as Option from "@effect/data/Option"; import type { Pipeable } from "@effect/data/Pipeable"; import type { Predicate } from "@effect/data/Predicate"; import type * as Unify from "@effect/data/Unify"; import type * as Cause from "@effect/io/Cause"; import type * as Deferred from "@effect/io/Deferred"; import type * as Effect from "@effect/io/Effect"; import type * as Exit from "@effect/io/Exit"; import type * as Hub from "@effect/io/Hub"; import type * as Layer from "@effect/io/Layer"; import type * as Queue from "@effect/io/Queue"; import type * as Ref from "@effect/io/Ref"; import type * as Scope from "@effect/io/Scope"; import type * as Tracer from "@effect/io/Tracer"; import type * as ChildExecutorDecision from "@effect/stream/Channel/ChildExecutorDecision"; import type * as MergeDecision from "@effect/stream/Channel/MergeDecision"; import type * as MergeStrategy from "@effect/stream/Channel/MergeStrategy"; import type * as SingleProducerAsyncInput from "@effect/stream/Channel/SingleProducerAsyncInput"; import type * as UpstreamPullRequest from "@effect/stream/Channel/UpstreamPullRequest"; import type * as UpstreamPullStrategy from "@effect/stream/Channel/UpstreamPullStrategy"; import type * as Sink from "@effect/stream/Sink"; import type * as Stream from "@effect/stream/Stream"; /** * @since 1.0.0 * @category symbols */ export declare const ChannelTypeId: unique symbol; /** * @since 1.0.0 * @category symbols */ export type ChannelTypeId = typeof ChannelTypeId; /** * A `Channel` is a nexus of I/O operations, which supports both reading and * writing. A channel may read values of type `InElem` and write values of type * `OutElem`. When the channel finishes, it yields a value of type `OutDone`. A * channel may fail with a value of type `OutErr`. * * Channels are the foundation of Streams: both streams and sinks are built on * channels. Most users shouldn't have to use channels directly, as streams and * sinks are much more convenient and cover all common use cases. However, when * adding new stream and sink operators, or doing something highly specialized, * it may be useful to use channels directly. * * Channels compose in a variety of ways: * * - **Piping**: One channel can be piped to another channel, assuming the * input type of the second is the same as the output type of the first. * - **Sequencing**: The terminal value of one channel can be used to create * another channel, and both the first channel and the function that makes * the second channel can be composed into a channel. * - **Concatenating**: The output of one channel can be used to create other * channels, which are all concatenated together. The first channel and the * function that makes the other channels can be composed into a channel. * * @since 1.0.0 * @category models */ export interface Channel extends Channel.Variance, Pipeable { [Unify.typeSymbol]?: unknown; [Unify.unifySymbol]?: ChannelUnify; [Unify.blacklistSymbol]?: ChannelUnifyBlacklist; } /** * @since 1.0.0 * @category models */ export interface ChannelUnify extends Effect.EffectUnify { Channel?: () => A[Unify.typeSymbol] extends Channel | infer _ ? Channel : never; } /** * @category models * @since 1.0.0 */ export interface ChannelUnifyBlacklist extends Effect.EffectUnifyBlacklist { Channel?: true; } /** * @since 1.0.0 * @category models */ declare module "@effect/io/Effect" { interface Effect extends Channel { } interface EffectUnifyBlacklist { Channel?: true; } } /** * @since 1.0.0 */ export declare namespace Channel { /** * @since 1.0.0 * @category models */ interface Variance { readonly [ChannelTypeId]: { _Env: (_: never) => Env; _InErr: (_: InErr) => void; _InElem: (_: InElem) => void; _InDone: (_: InDone) => void; _OutErr: (_: never) => OutErr; _OutElem: (_: never) => OutElem; _OutDone: (_: never) => OutDone; }; } } /** * @since 1.0.0 * @category symbols */ export declare const ChannelExceptionTypeId: unique symbol; /** * @since 1.0.0 * @category symbols */ export type ChannelExceptionTypeId = typeof ChannelExceptionTypeId; /** * Represents a generic checked exception which occurs when a `Channel` is * executed. * * @since 1.0.0 * @category models */ export interface ChannelException { readonly _tag: "ChannelException"; readonly [ChannelExceptionTypeId]: ChannelExceptionTypeId; readonly error: E; } /** * @since 1.0.0 * @category constructors */ export declare const acquireUseRelease: (acquire: Effect.Effect, use: (a: Acquired) => Channel, release: (a: Acquired, exit: Exit.Exit) => Effect.Effect) => Channel; /** * @since 1.0.0 * @category constructors */ export declare const acquireReleaseOut: (self: Effect.Effect, release: (z: Z, e: Exit.Exit) => Effect.Effect) => Channel; /** * Returns a new channel that is the same as this one, except the terminal * value of the channel is the specified constant value. * * This method produces the same result as mapping this channel to the * specified constant value. * * @since 1.0.0 * @category mapping */ export declare const as: { (value: OutDone2): (self: Channel) => Channel; (self: Channel, value: OutDone2): Channel; }; /** * @since 1.0.0 * @category mapping */ export declare const asUnit: (self: Channel) => Channel; /** * Creates a channel backed by a buffer. When the buffer is empty, the channel * will simply passthrough its input as output. However, when the buffer is * non-empty, the value inside the buffer will be passed along as output. * * @since 1.0.0 * @category constructors */ export declare const buffer: (options: { readonly empty: InElem; readonly isEmpty: Predicate; readonly ref: Ref.Ref; }) => Channel; /** * @since 1.0.0 * @category constructors */ export declare const bufferChunk: (ref: Ref.Ref>) => Channel, InDone, InErr, Chunk.Chunk, InDone>; /** * Returns a new channel that is the same as this one, except if this channel * errors for any typed error, then the returned channel will switch over to * using the fallback channel returned by the specified error handler. * * @since 1.0.0 * @category error handling */ export declare const catchAll: { (f: (error: OutErr) => Channel): (self: Channel) => Channel; (self: Channel, f: (error: OutErr) => Channel): Channel; }; /** * Returns a new channel that is the same as this one, except if this channel * errors for any typed error, then the returned channel will switch over to * using the fallback channel returned by the specified error handler. * * @since 1.0.0 * @category error handling */ export declare const catchAllCause: { (f: (cause: Cause.Cause) => Channel): (self: Channel) => Channel; (self: Channel, f: (cause: Cause.Cause) => Channel): Channel; }; /** * Concat sequentially a channel of channels. * * @since 1.0.0 * @category constructors */ export declare const concatAll: (channels: Channel, any>) => Channel; /** * Concat sequentially a channel of channels. * * @since 1.0.0 * @category constructors */ export declare const concatAllWith: (channels: Channel, OutDone2>, f: (o: OutDone, o1: OutDone) => OutDone, g: (o: OutDone, o2: OutDone2) => OutDone3) => Channel; /** * Returns a new channel whose outputs are fed to the specified factory * function, which creates new channels in response. These new channels are * sequentially concatenated together, and all their outputs appear as outputs * of the newly returned channel. * * @since 1.0.0 * @category utils */ export declare const concatMap: { (f: (o: OutElem) => Channel): (self: Channel) => Channel; (self: Channel, f: (o: OutElem) => Channel): Channel; }; /** * Returns a new channel whose outputs are fed to the specified factory * function, which creates new channels in response. These new channels are * sequentially concatenated together, and all their outputs appear as outputs * of the newly returned channel. The provided merging function is used to * merge the terminal values of all channels into the single terminal value of * the returned channel. * * @since 1.0.0 * @category utils */ export declare const concatMapWith: { (f: (o: OutElem) => Channel, g: (o: OutDone, o1: OutDone) => OutDone, h: (o: OutDone, o2: OutDone2) => OutDone3): (self: Channel) => Channel; (self: Channel, f: (o: OutElem) => Channel, g: (o: OutDone, o1: OutDone) => OutDone, h: (o: OutDone, o2: OutDone2) => OutDone3): Channel; }; /** * Returns a new channel whose outputs are fed to the specified factory * function, which creates new channels in response. These new channels are * sequentially concatenated together, and all their outputs appear as outputs * of the newly returned channel. The provided merging function is used to * merge the terminal values of all channels into the single terminal value of * the returned channel. * * @since 1.0.0 * @category utils */ export declare const concatMapWithCustom: { (f: (o: OutElem) => Channel, g: (o: OutDone, o1: OutDone) => OutDone, h: (o: OutDone, o2: OutDone2) => OutDone3, onPull: (upstreamPullRequest: UpstreamPullRequest.UpstreamPullRequest) => UpstreamPullStrategy.UpstreamPullStrategy, onEmit: (elem: OutElem2) => ChildExecutorDecision.ChildExecutorDecision): (self: Channel) => Channel; (self: Channel, f: (o: OutElem) => Channel, g: (o: OutDone, o1: OutDone) => OutDone, h: (o: OutDone, o2: OutDone2) => OutDone3, onPull: (upstreamPullRequest: UpstreamPullRequest.UpstreamPullRequest) => UpstreamPullStrategy.UpstreamPullStrategy, onEmit: (elem: OutElem2) => ChildExecutorDecision.ChildExecutorDecision): Channel; }; /** * Returns a new channel, which is the same as this one, except its outputs * are filtered and transformed by the specified partial function. * * @since 1.0.0 * @category utils */ export declare const collect: { (pf: (o: OutElem) => Option.Option): (self: Channel) => Channel; (self: Channel, pf: (o: OutElem) => Option.Option): Channel; }; /** * Returns a new channel, which is the concatenation of all the channels that * are written out by this channel. This method may only be called on channels * that output other channels. * * @since 1.0.0 * @category utils */ export declare const concatOut: (self: Channel, OutDone>) => Channel; /** * Returns a new channel which is the same as this one but applies the given * function to the input channel's done value. * * @since 1.0.0 * @category utils */ export declare const mapInput: { (f: (a: InDone0) => InDone): (self: Channel) => Channel; (self: Channel, f: (a: InDone0) => InDone): Channel; }; /** * Returns a new channel which is the same as this one but applies the given * effectual function to the input channel's done value. * * @since 1.0.0 * @category utils */ export declare const mapInputEffect: { (f: (i: InDone0) => Effect.Effect): (self: Channel) => Channel; (self: Channel, f: (i: InDone0) => Effect.Effect): Channel; }; /** * Returns a new channel which is the same as this one but applies the given * function to the input channel's error value. * * @since 1.0.0 * @category utils */ export declare const mapInputError: { (f: (a: InErr0) => InErr): (self: Channel) => Channel; (self: Channel, f: (a: InErr0) => InErr): Channel; }; /** * Returns a new channel which is the same as this one but applies the given * effectual function to the input channel's error value. * * @since 1.0.0 * @category utils */ export declare const mapInputErrorEffect: { (f: (error: InErr0) => Effect.Effect): (self: Channel) => Channel; (self: Channel, f: (error: InErr0) => Effect.Effect): Channel; }; /** * Returns a new channel which is the same as this one but applies the given * function to the input channel's output elements. * * @since 1.0.0 * @category utils */ export declare const mapInputIn: { (f: (a: InElem0) => InElem): (self: Channel) => Channel; (self: Channel, f: (a: InElem0) => InElem): Channel; }; /** * Returns a new channel which is the same as this one but applies the given * effectual function to the input channel's output elements. * * @since 1.0.0 * @category utils */ export declare const mapInputInEffect: { (f: (a: InElem0) => Effect.Effect): (self: Channel) => Channel; (self: Channel, f: (a: InElem0) => Effect.Effect): Channel; }; /** * Returns a new channel, which is the same as this one, except that all the * outputs are collected and bundled into a tuple together with the terminal * value of this channel. * * As the channel returned from this channel collects all of this channel's * output into an in- memory chunk, it is not safe to call this method on * channels that output a large or unbounded number of values. * * @since 1.0.0 * @category utils */ export declare const doneCollect: (self: Channel) => Channel, OutDone]>; /** * Returns a new channel which reads all the elements from upstream's output * channel and ignores them, then terminates with the upstream result value. * * @since 1.0.0 * @category utils */ export declare const drain: (self: Channel) => Channel; /** * Returns a new channel which connects the given `AsyncInputProducer` as * this channel's input. * * @since 1.0.0 * @category utils */ export declare const embedInput: { (input: SingleProducerAsyncInput.AsyncInputProducer): (self: Channel) => Channel; (self: Channel, input: SingleProducerAsyncInput.AsyncInputProducer): Channel; }; /** * Returns a new channel that collects the output and terminal value of this * channel, which it then writes as output of the returned channel. * * @since 1.0.0 * @category utils */ export declare const emitCollect: (self: Channel) => Channel, OutDone], void>; /** * Returns a new channel with an attached finalizer. The finalizer is * guaranteed to be executed so long as the channel begins execution (and * regardless of whether or not it completes). * * @since 1.0.0 * @category utils */ export declare const ensuring: { (finalizer: Effect.Effect): (self: Channel) => Channel; (self: Channel, finalizer: Effect.Effect): Channel; }; /** * Returns a new channel with an attached finalizer. The finalizer is * guaranteed to be executed so long as the channel begins execution (and * regardless of whether or not it completes). * * @since 1.0.0 * @category utils */ export declare const ensuringWith: { (finalizer: (e: Exit.Exit) => Effect.Effect): (self: Channel) => Channel; (self: Channel, finalizer: (e: Exit.Exit) => Effect.Effect): Channel; }; /** * Accesses the whole context of the channel. * * @since 1.0.0 * @category context */ export declare const context: () => Channel>; /** * Accesses the context of the channel with the specified function. * * @since 1.0.0 * @category context */ export declare const contextWith: (f: (env: Context.Context) => OutDone) => Channel; /** * Accesses the context of the channel in the context of a channel. * * @since 1.0.0 * @category context */ export declare const contextWithChannel: (f: (env: Context.Context) => Channel) => Channel; /** * Accesses the context of the channel in the context of an effect. * * @since 1.0.0 * @category context */ export declare const contextWithEffect: (f: (env: Context.Context) => Effect.Effect) => Channel; /** * Constructs a channel that fails immediately with the specified error. * * @since 1.0.0 * @category constructors */ export declare const fail: (error: E) => Channel; /** * Constructs a channel that succeeds immediately with the specified lazily * evaluated value. * * @since 1.0.0 * @category constructors */ export declare const failSync: (evaluate: LazyArg) => Channel; /** * Constructs a channel that fails immediately with the specified `Cause`. * * @since 1.0.0 * @category constructors */ export declare const failCause: (cause: Cause.Cause) => Channel; /** * Constructs a channel that succeeds immediately with the specified lazily * evaluated `Cause`. * * @since 1.0.0 * @category constructors */ export declare const failCauseSync: (evaluate: LazyArg>) => Channel; /** * Returns a new channel, which sequentially combines this channel, together * with the provided factory function, which creates a second channel based on * the terminal value of this channel. The result is a channel that will first * perform the functions of this channel, before performing the functions of * the created channel (including yielding its terminal value). * * @since 1.0.0 * @category sequencing */ export declare const flatMap: { (f: (d: OutDone) => Channel): (self: Channel) => Channel; (self: Channel, f: (d: OutDone) => Channel): Channel; }; /** * Returns a new channel, which flattens the terminal value of this channel. * This function may only be called if the terminal value of this channel is * another channel of compatible types. * * @since 1.0.0 * @category sequencing */ export declare const flatten: (self: Channel>) => Channel; /** * Folds over the result of this channel. * * @since 1.0.0 * @category utils */ export declare const foldChannel: { (options: { readonly onFailure: (error: OutErr) => Channel; readonly onSuccess: (done: OutDone) => Channel; }): (self: Channel) => Channel; (self: Channel, options: { readonly onFailure: (error: OutErr) => Channel; readonly onSuccess: (done: OutDone) => Channel; }): Channel; }; /** * Folds over the result of this channel including any cause of termination. * * @since 1.0.0 * @category utils */ export declare const foldCauseChannel: { (options: { readonly onFailure: (c: Cause.Cause) => Channel; readonly onSuccess: (o: OutDone) => Channel; }): (self: Channel) => Channel; (self: Channel, options: { readonly onFailure: (c: Cause.Cause) => Channel; readonly onSuccess: (o: OutDone) => Channel; }): Channel; }; /** * Use an effect to end a channel. * * @since 1.0.0 * @category constructors */ export declare const fromEffect: (effect: Effect.Effect) => Channel; /** * Constructs a channel from an `Either`. * * @since 1.0.0 * @category constructors */ export declare const fromEither: (either: Either.Either) => Channel; /** * Construct a `Channel` from an `AsyncInputConsumer`. * * @since 1.0.0 * @category constructors */ export declare const fromInput: (input: SingleProducerAsyncInput.AsyncInputConsumer) => Channel; /** * Construct a `Channel` from a `Hub`. * * @since 1.0.0 * @category constructors */ export declare const fromHub: (hub: Hub.Hub, Elem>>) => Channel; /** * Construct a `Channel` from a `Hub` within a scoped effect. * * @since 1.0.0 * @category constructors */ export declare const fromHubScoped: (hub: Hub.Hub, Elem>>) => Effect.Effect>; /** * Construct a `Channel` from an `Option`. * * @since 1.0.0 * @category constructors */ export declare const fromOption: (option: Option.Option) => Channel, never, A>; /** * Construct a `Channel` from a `Queue`. * * @since 1.0.0 * @category constructors */ export declare const fromQueue: (queue: Queue.Dequeue, Elem>>) => Channel; /** * @since 1.0.0 * @category constructors */ export declare const identity: () => Channel; /** * Returns a new channel, which is the same as this one, except it will be * interrupted when the specified effect completes. If the effect completes * successfully before the underlying channel is done, then the returned * channel will yield the success value of the effect as its terminal value. * On the other hand, if the underlying channel finishes first, then the * returned channel will yield the success value of the underlying channel as * its terminal value. * * @since 1.0.0 * @category utils */ export declare const interruptWhen: { (effect: Effect.Effect): (self: Channel) => Channel; (self: Channel, effect: Effect.Effect): Channel; }; /** * Returns a new channel, which is the same as this one, except it will be * interrupted when the specified deferred is completed. If the deferred is * completed before the underlying channel is done, then the returned channel * will yield the value of the deferred. Otherwise, if the underlying channel * finishes first, then the returned channel will yield the value of the * underlying channel. * * @since 1.0.0 * @category utils */ export declare const interruptWhenDeferred: { (deferred: Deferred.Deferred): (self: Channel) => Channel; (self: Channel, deferred: Deferred.Deferred): Channel; }; /** * Returns a new channel, which is the same as this one, except the terminal * value of the returned channel is created by applying the specified function * to the terminal value of this channel. * * @since 1.0.0 * @category mapping */ export declare const map: { (f: (out: OutDone) => OutDone2): (self: Channel) => Channel; (self: Channel, f: (out: OutDone) => OutDone2): Channel; }; /** * Returns a new channel, which is the same as this one, except the terminal * value of the returned channel is created by applying the specified * effectful function to the terminal value of this channel. * * @since 1.0.0 * @category mapping */ export declare const mapEffect: { (f: (o: OutDone) => Effect.Effect): (self: Channel) => Channel; (self: Channel, f: (o: OutDone) => Effect.Effect): Channel; }; /** * Returns a new channel, which is the same as this one, except the failure * value of the returned channel is created by applying the specified function * to the failure value of this channel. * * @since 1.0.0 * @category mapping */ export declare const mapError: { (f: (err: OutErr) => OutErr2): (self: Channel) => Channel; (self: Channel, f: (err: OutErr) => OutErr2): Channel; }; /** * A more powerful version of `mapError` which also surfaces the `Cause` * of the channel failure. * * @since 1.0.0 * @category mapping */ export declare const mapErrorCause: { (f: (cause: Cause.Cause) => Cause.Cause): (self: Channel) => Channel; (self: Channel, f: (cause: Cause.Cause) => Cause.Cause): Channel; }; /** * Maps the output of this channel using the specified function. * * @since 1.0.0 * @category mapping */ export declare const mapOut: { (f: (o: OutElem) => OutElem2): (self: Channel) => Channel; (self: Channel, f: (o: OutElem) => OutElem2): Channel; }; /** * Creates a channel that is like this channel but the given effectful function * gets applied to each emitted output element. * * @since 1.0.0 * @category mapping */ export declare const mapOutEffect: { (f: (o: OutElem) => Effect.Effect): (self: Channel) => Channel; (self: Channel, f: (o: OutElem) => Effect.Effect): Channel; }; /** * Creates a channel that is like this channel but the given ZIO function gets * applied to each emitted output element, taking `n` elements at once and * mapping them in parallel. * * @since 1.0.0 * @category mapping */ export declare const mapOutEffectPar: { (f: (o: OutElem) => Effect.Effect, n: number): (self: Channel) => Channel; (self: Channel, f: (o: OutElem) => Effect.Effect, n: number): Channel; }; /** * @since 1.0.0 * @category utils */ export declare const mergeAll: (options: { readonly concurrency: number | "unbounded"; readonly bufferSize?: number; readonly mergeStrategy?: MergeStrategy.MergeStrategy; }) => (channels: Channel, unknown>) => Channel; /** * @since 1.0.0 * @category utils */ export declare const mergeAllUnbounded: (channels: Channel, unknown>) => Channel; /** * @since 1.0.0 * @category utils */ export declare const mergeAllUnboundedWith: (channels: Channel, OutDone>, f: (o1: OutDone, o2: OutDone) => OutDone) => Channel; /** * @since 1.0.0 * @category utils */ export declare const mergeAllWith: ({ bufferSize, concurrency, mergeStrategy }: { readonly concurrency: number | "unbounded"; readonly bufferSize?: number; readonly mergeStrategy?: MergeStrategy.MergeStrategy; }) => (channels: Channel, OutDone>, f: (o1: OutDone, o2: OutDone) => OutDone) => Channel; /** * Returns a new channel which creates a new channel for each emitted element * and merges some of them together. Different merge strategies control what * happens if there are more than the given maximum number of channels gets * created. See `Channel.mergeAll`. * * @param n The maximum number of channels to merge. * @param f The function that creates a new channel from each emitted element. * @since 1.0.0 * @category mapping */ export declare const mergeMap: { (f: (outElem: OutElem) => Channel, options: { readonly concurrency: number | "unbounded"; readonly bufferSize?: number; readonly mergeStrategy?: MergeStrategy.MergeStrategy; }): (self: Channel) => Channel; (self: Channel, f: (outElem: OutElem) => Channel, options: { readonly concurrency: number | "unbounded"; readonly bufferSize?: number; readonly mergeStrategy?: MergeStrategy.MergeStrategy; }): Channel; }; /** * Returns a new channel which merges a number of channels emitted by this * channel using the back pressuring merge strategy. See `Channel.mergeAll`. * * @since 1.0.0 * @category utils */ export declare const mergeOut: { (n: number): (self: Channel, OutDone>) => Channel; (self: Channel, OutDone>, n: number): Channel; }; /** * Returns a new channel which merges a number of channels emitted by this * channel using the back pressuring merge strategy and uses a given function * to merge each completed subchannel's result value. See * `Channel.mergeAll`. * * @since 1.0.0 * @category utils */ export declare const mergeOutWith: { (n: number, f: (o1: OutDone1, o2: OutDone1) => OutDone1): (self: Channel, OutDone1>) => Channel; (self: Channel, OutDone1>, n: number, f: (o1: OutDone1, o2: OutDone1) => OutDone1): Channel; }; /** * Returns a new channel, which is the merge of this channel and the specified * channel, where the behavior of the returned channel on left or right early * termination is decided by the specified `leftDone` and `rightDone` merge * decisions. * * @since 1.0.0 * @category utils */ export declare const mergeWith: { (options: { readonly other: Channel; readonly onSelfDone: (exit: Exit.Exit) => MergeDecision.MergeDecision; readonly onOtherDone: (ex: Exit.Exit) => MergeDecision.MergeDecision; }): (self: Channel) => Channel; (self: Channel, options: { readonly other: Channel; readonly onSelfDone: (exit: Exit.Exit) => MergeDecision.MergeDecision; readonly onOtherDone: (ex: Exit.Exit) => MergeDecision.MergeDecision; }): Channel; }; /** * Returns a channel that never completes * * @since 1.0.0 * @category constructors */ export declare const never: Channel; /** * Translates channel failure into death of the fiber, making all failures * unchecked and not a part of the type of the channel. * * @since 1.0.0 * @category error handling */ export declare const orDie: { (error: LazyArg): (self: Channel) => Channel; (self: Channel, error: LazyArg): Channel; }; /** * Keeps none of the errors, and terminates the fiber with them, using the * specified function to convert the `OutErr` into a defect. * * @since 1.0.0 * @category error handling */ export declare const orDieWith: { (f: (e: OutErr) => unknown): (self: Channel) => Channel; (self: Channel, f: (e: OutErr) => unknown): Channel; }; /** * Returns a new channel that will perform the operations of this one, until * failure, and then it will switch over to the operations of the specified * fallback channel. * * @since 1.0.0 * @category error handling */ export declare const orElse: { (that: LazyArg>): (self: Channel) => Channel; (self: Channel, that: LazyArg>): Channel; }; /** * Returns a new channel that pipes the output of this channel into the * specified channel. The returned channel has the input type of this channel, * and the output type of the specified channel, terminating with the value of * the specified channel. * * @since 1.0.0 * @category utils */ export declare const pipeTo: { (that: Channel): (self: Channel) => Channel; (self: Channel, that: Channel): Channel; }; /** * Returns a new channel that pipes the output of this channel into the * specified channel and preserves this channel's failures without providing * them to the other channel for observation. * * @since 1.0.0 * @category utils */ export declare const pipeToOrFail: { (that: Channel): (self: Channel) => Channel; (self: Channel, that: Channel): Channel; }; /** * Provides the channel with its required context, which eliminates its * dependency on `Env`. * * @since 1.0.0 * @category context */ export declare const provideContext: { (env: Context.Context): (self: Channel) => Channel; (self: Channel, env: Context.Context): Channel; }; /** * Provides a layer to the channel, which translates it to another level. * * @since 1.0.0 * @category context */ export declare const provideLayer: { (layer: Layer.Layer): (self: Channel) => Channel; (self: Channel, layer: Layer.Layer): Channel; }; /** * Transforms the context being provided to the channel with the specified * function. * * @since 1.0.0 * @category context */ export declare const mapInputContext: { (f: (env: Context.Context) => Context.Context): (self: Channel) => Channel; (self: Channel, f: (env: Context.Context) => Context.Context): Channel; }; /** * Splits the context into two parts, providing one part using the * specified layer and leaving the remainder `Env0`. * * @since 1.0.0 * @category context */ export declare const provideSomeLayer: { (layer: Layer.Layer): (self: Channel) => Channel, InErr, InElem, InDone, OutErr2 | OutErr, OutElem, OutDone>; (self: Channel, layer: Layer.Layer): Channel, InErr, InElem, InDone, OutErr | OutErr2, OutElem, OutDone>; }; /** * Provides the effect with the single service it requires. If the effect * requires more than one service use `provideContext` instead. * * @since 1.0.0 * @category context */ export declare const provideService: { >(tag: T, service: Context.Tag.Service): (self: Channel) => Channel>, InErr, InElem, InDone, OutErr, OutElem, OutDone>; >(self: Channel, tag: T, service: Context.Tag.Service): Channel>, InErr, InElem, InDone, OutErr, OutElem, OutDone>; }; /** * @since 1.0.0 * @category constructors */ export declare const read: () => Channel, never, In>; /** * @since 1.0.0 * @category constructors */ export declare const readOrFail: (error: E) => Channel; /** * @since 1.0.0 * @category constructors */ export declare const readWith: (options: { readonly onInput: (input: InElem) => Channel; readonly onFailure: (error: InErr) => Channel; readonly onDone: (done: InDone) => Channel; }) => Channel; /** * @since 1.0.0 * @category constructors */ export declare const readWithCause: (options: { readonly onInput: (input: InElem) => Channel; readonly onFailure: (cause: Cause.Cause) => Channel; readonly onDone: (done: InDone) => Channel; }) => Channel; /** * Creates a channel which repeatedly runs this channel. * * @since 1.0.0 * @category utils */ export declare const repeated: (self: Channel) => Channel; /** * Runs a channel until the end is received. * * @since 1.0.0 * @category destructors */ export declare const run: (self: Channel) => Effect.Effect; /** * Run the channel until it finishes with a done value or fails with an error * and collects its emitted output elements. * * The channel must not read any input. * * @since 1.0.0 * @category destructors */ export declare const runCollect: (self: Channel) => Effect.Effect, OutDone]>; /** * Runs a channel until the end is received. * * @since 1.0.0 * @category destructors */ export declare const runDrain: (self: Channel) => Effect.Effect; /** * Use a scoped effect to emit an output element. * * @since 1.0.0 * @category constructors */ export declare const scoped: (effect: Effect.Effect) => Channel, unknown, unknown, unknown, E, A, unknown>; /** * Constructs a channel that succeeds immediately with the specified value. * * @since 1.0.0 * @category constructors */ export declare const succeed: (value: A) => Channel; /** * Constructs a channel that succeeds immediately with the specified lazy value. * * @since 1.0.0 * @category constructors */ export declare const sync: (evaluate: LazyArg) => Channel; /** * Converts a `Channel` to a `Hub`. * * @since 1.0.0 * @category destructors */ export declare const toHub: (hub: Hub.Hub, Elem>>) => Channel; /** * Returns a scoped `Effect` that can be used to repeatedly pull elements from * the constructed `Channel`. The pull effect fails with the channel's failure * in case the channel fails, or returns either the channel's done value or an * emitted element. * * @since 1.0.0 * @category destructors */ export declare const toPull: (self: Channel) => Effect.Effect>>; /** * Converts a `Channel` to a `Queue`. * * @since 1.0.0 * @category destructors */ export declare const toQueue: (queue: Queue.Enqueue, Elem>>) => Channel; /** Converts this channel to a `Sink`. * * @since 1.0.0 * @category destructors */ export declare const toSink: (self: Channel, unknown, OutErr, Chunk.Chunk, OutDone>) => Sink.Sink; /** * Converts this channel to a `Stream`. * * @since 1.0.0 * @category destructors */ export declare const toStream: (self: Channel, OutDone>) => Stream.Stream; /** * @since 1.0.0 * @category constructors */ export declare const unit: Channel; /** * Makes a channel from an effect that returns a channel in case of success. * * @since 1.0.0 * @category constructors */ export declare const unwrap: (channel: Effect.Effect>) => Channel; /** * Makes a channel from a managed that returns a channel in case of success. * * @since 1.0.0 * @category constructors */ export declare const unwrapScoped: (self: Effect.Effect>) => Channel, InErr, InElem, InDone, E | OutErr, OutElem, OutDone>; /** * Updates a service in the context of this channel. * * @since 1.0.0 * @category context */ export declare const updateService: { >(tag: T, f: (resource: Context.Tag.Service) => Context.Tag.Service): (self: Channel) => Channel; >(self: Channel, tag: T, f: (resource: Context.Tag.Service) => Context.Tag.Service): Channel; }; /** * Wraps the channel with a new span for tracing. * * @since 1.0.0 * @category tracing */ export declare const withSpan: { (name: string, options?: { readonly attributes?: Record; readonly links?: ReadonlyArray; readonly parent?: Tracer.ParentSpan; readonly root?: boolean; readonly context?: Context.Context; }): (self: Channel) => Channel; (self: Channel, name: string, options?: { readonly attributes?: Record; readonly links?: ReadonlyArray; readonly parent?: Tracer.ParentSpan; readonly root?: boolean; readonly context?: Context.Context; }): Channel; }; /** * Writes a single value to the channel. * * @since 1.0.0 * @category constructors */ export declare const write: (out: OutElem) => Channel; /** * Writes a sequence of values to the channel. * * @since 1.0.0 * @category constructors */ export declare const writeAll: >(...outs: OutElems) => Channel; /** * Writes a `Chunk` of values to the channel. * * @since 1.0.0 * @category constructors */ export declare const writeChunk: (outs: Chunk.Chunk) => Channel; /** * Returns a new channel that is the sequential composition of this channel * and the specified channel. The returned channel terminates with a tuple of * the terminal values of both channels. * * @since 1.0.0 * @category zipping */ export declare const zip: { (that: Channel, options?: { readonly concurrent?: boolean; }): (self: Channel) => Channel; (self: Channel, that: Channel, options?: { readonly concurrent?: boolean; }): Channel; }; /** * Returns a new channel that is the sequential composition of this channel * and the specified channel. The returned channel terminates with the * terminal value of this channel. * * @since 1.0.0 * @category zipping */ export declare const zipLeft: { (that: Channel, options?: { readonly concurrent?: boolean; }): (self: Channel) => Channel; (self: Channel, that: Channel, options?: { readonly concurrent?: boolean; }): Channel; }; /** * Returns a new channel that is the sequential composition of this channel * and the specified channel. The returned channel terminates with the * terminal value of that channel. * * @since 1.0.0 * @category zipping */ export declare const zipRight: { (that: Channel, options?: { readonly concurrent?: boolean; }): (self: Channel) => Channel; (self: Channel, that: Channel, options?: { readonly concurrent?: boolean; }): Channel; }; /** * Represents a generic checked exception which occurs when a `Channel` is * executed. * * @since 1.0.0 * @category errors */ export declare const ChannelException: (error: E) => ChannelException; /** * Returns `true` if the specified value is an `ChannelException`, `false` * otherwise. * * @since 1.0.0 * @category refinements */ export declare const isChannelException: (u: unknown) => u is ChannelException; //# sourceMappingURL=Channel.d.ts.map