effect-io-ai

Package: effect
Module: Schema

Schema.Codec

A schema that tracks the decoded type T, the encoded type E, and the Effect services required during decoding (RD) and encoding (RE).

Details

Use Codec<T, E, RD, RE> when you need to preserve full type information about a schema — both what it decodes to and what it serializes from/to. Most concrete schemas produced by this module implement Codec.

For APIs that only need one direction, prefer the narrower views:

Example (Accepting a codec that decodes to number from string)

import { Schema } from "effect"

declare function serialize<T>(codec: Schema.Codec<T, string>): string

serialize(Schema.NumberFromString) // ok — decodes number, encoded as string

See

Signature

export interface Codec<out T, out E = T, out RD = never, out RE = never> extends Schema<T> {
  readonly "Encoded": E
  readonly "DecodingServices": RD
  readonly "EncodingServices": RE
  readonly "Rebuild": Codec<T, E, RD, RE>
}

Source

Since v4.0.0