/** * @since 4.0.0 */ import * as Context from "./Context.ts" import * as Effect from "./Effect.ts" import * as Layer from "./Layer.ts" import type { PlatformError } from "./PlatformError.ts" import * as Sink from "./Sink.ts" import * as Stream from "./Stream.ts" /** * @since 4.0.0 * @category Type IDs */ export type TypeId = "~effect/Stdio" /** * @since 4.0.0 * @category Type IDs */ export const TypeId: TypeId = "~effect/Stdio" /** * @since 4.0.0 * @category Models */ export interface Stdio { readonly [TypeId]: TypeId readonly args: Effect.Effect> stdout(options?: { readonly endOnDone?: boolean | undefined }): Sink.Sink stderr(options?: { readonly endOnDone?: boolean | undefined }): Sink.Sink readonly stdin: Stream.Stream } /** * @since 4.0.0 * @category Services */ export const Stdio: Context.Service = Context.Service(TypeId) /** * @since 4.0.0 * @category Constructors */ export const make = (options: Omit): Stdio => ({ [TypeId]: TypeId, ...options }) /** * @since 4.0.0 * @category Layers */ export const layerTest = (impl: Partial): Layer.Layer => Layer.succeed( Stdio, make({ args: Effect.succeed([]), stdout: () => Sink.drain, stderr: () => Sink.drain, stdin: Stream.empty, ...impl }) )