# encode

Encodes each matched schema Type to its Encoded representation.

## Signatures

```ts
export declare const encode: {
    <S extends Schema.Top>(schema: S): <I, E = never, R = never>(guard: GuardInput<I, S["Type"], E, R>) => Guard<I, S["Encoded"], Schema.SchemaError | E, R | S["EncodingServices"]>;
    <I, E, R, S extends Schema.Top>(guard: GuardInput<I, S["Type"], E, R>, schema: S): Guard<I, S["Encoded"], Schema.SchemaError | E, R | S["EncodingServices"]>;
};
```

## Why

The composed Guard preserves source non-match and errors while adding schema failures and encoding service requirements.

## Ownership and lifetime

Construction acquires no resources; encoding starts only for `Some` and follows that invocation's lifetime.

## Examples

```ts
import { encode, liftPredicate } from "@typed/guard"
import { Schema } from "effect"
const text = encode(liftPredicate((u: unknown): u is number => typeof u === "number"), Schema.NumberFromString)
```
