Serializable overview
Added in v0.67.0
Table of contents
- accessor
- decoding
- encoding
- model
- symbol
- utils
accessor
exitSchema
Signature
export declare const exitSchema: <SA, SI, FA, FI, R>(
self: WithResult<SA, SI, FA, FI, R>
) => Schema.Schema<Exit.Exit<SA, FA>, Schema.ExitEncoded<SI, FI, unknown>, R>
Added in v0.67.0
failureSchema
Signature
export declare const failureSchema: <SA, SI, FA, FI, R>(self: WithResult<SA, SI, FA, FI, R>) => Schema.Schema<FA, FI, R>
Added in v0.67.0
selfSchema
Signature
export declare const selfSchema: <A, I, R>(self: Serializable<A, I, R>) => Schema.Schema<A, I, R>
Added in v0.67.0
successSchema
Signature
export declare const successSchema: <SA, SI, FA, FI, R>(self: WithResult<SA, SI, FA, FI, R>) => Schema.Schema<SA, SI, R>
Added in v0.67.0
decoding
deserialize
Signature
export declare const deserialize: {
(value: unknown): <A, I, R>(self: Serializable<A, I, R>) => Effect.Effect<A, ParseResult.ParseError, R>
<A, I, R>(self: Serializable<A, I, R>, value: unknown): Effect.Effect<A, ParseResult.ParseError, R>
}
Added in v0.67.0
deserializeExit
Signature
export declare const deserializeExit: {
(
value: unknown
): <SA, SI, FA, FI, R>(
self: WithResult<SA, SI, FA, FI, R>
) => Effect.Effect<Exit.Exit<SA, FA>, ParseResult.ParseError, R>
<SA, SI, FA, FI, R>(
self: WithResult<SA, SI, FA, FI, R>,
value: unknown
): Effect.Effect<Exit.Exit<SA, FA>, ParseResult.ParseError, R>
}
Added in v0.67.0
deserializeFailure
Signature
export declare const deserializeFailure: {
(
value: unknown
): <SA, SI, FA, FI, R>(self: WithResult<SA, SI, FA, FI, R>) => Effect.Effect<FA, ParseResult.ParseError, R>
<SA, SI, FA, FI, R>(self: WithResult<SA, SI, FA, FI, R>, value: unknown): Effect.Effect<FA, ParseResult.ParseError, R>
}
Added in v0.67.0
deserializeSuccess
Signature
export declare const deserializeSuccess: {
(
value: unknown
): <SA, SI, FA, FI, R>(self: WithResult<SA, SI, FA, FI, R>) => Effect.Effect<SA, ParseResult.ParseError, R>
<SA, SI, FA, FI, R>(self: WithResult<SA, SI, FA, FI, R>, value: unknown): Effect.Effect<SA, ParseResult.ParseError, R>
}
Added in v0.67.0
encoding
serialize
Signature
export declare const serialize: <A, I, R>(self: Serializable<A, I, R>) => Effect.Effect<I, ParseResult.ParseError, R>
Added in v0.67.0
serializeExit
Signature
export declare const serializeExit: {
<SA, FA>(
value: Exit.Exit<SA, FA>
): <SI, FI, R>(
self: WithResult<SA, SI, FA, FI, R>
) => Effect.Effect<Schema.ExitEncoded<SI, FI, unknown>, ParseResult.ParseError, R>
<SA, SI, FA, FI, R>(
self: WithResult<SA, SI, FA, FI, R>,
value: Exit.Exit<SA, FA>
): Effect.Effect<Schema.ExitEncoded<SI, FI, unknown>, ParseResult.ParseError, R>
}
Added in v0.67.0
serializeFailure
Signature
export declare const serializeFailure: {
<FA>(value: FA): <SA, SI, FI, R>(self: WithResult<SA, SI, FA, FI, R>) => Effect.Effect<FI, ParseResult.ParseError, R>
<SA, SI, FA, FI, R>(self: WithResult<SA, SI, FA, FI, R>, value: FA): Effect.Effect<FI, ParseResult.ParseError, R>
}
Added in v0.67.0
serializeSuccess
Signature
export declare const serializeSuccess: {
<SA>(value: SA): <SI, FA, FI, R>(self: WithResult<SA, SI, FA, FI, R>) => Effect.Effect<SI, ParseResult.ParseError, R>
<SA, SI, FA, FI, R>(self: WithResult<SA, SI, FA, FI, R>, value: SA): Effect.Effect<SI, ParseResult.ParseError, R>
}
Added in v0.67.0
model
Serializable (interface)
The Serializable
trait allows objects to define their own schema for serialization.
Signature
export interface Serializable<A, I, R> {
readonly [symbol]: Schema.Schema<A, I, R>
}
Added in v0.67.0
Serializable (namespace)
Added in v0.67.0
All (type alias)
Signature
export type All =
| Any
| Serializable<any, never, unknown>
| Serializable<never, any, unknown>
| Serializable<never, never, unknown>
Added in v0.69.0
Any (type alias)
Signature
export type Any = Serializable<any, any, unknown>
Added in v0.69.0
Context (type alias)
Signature
export type Context<T> = T extends Serializable<infer _A, infer _I, infer R> ? R : never
Added in v0.67.0
Encoded (type alias)
Signature
export type Encoded<T> = T extends Serializable<infer _A, infer I, infer _R> ? I : never
Added in v0.68.15
Type (type alias)
Signature
export type Type<T> = T extends Serializable<infer A, infer _I, infer _R> ? A : never
Added in v0.68.15
SerializableWithResult (interface)
The SerializableWithResult
trait is specifically designed to model remote procedures that require serialization of their input and output, managing both successful and failed outcomes.
This trait combines functionality from both the Serializable
and WithResult
traits to handle data serialization and the bifurcation of operation results into success or failure categories.
Signature
export interface SerializableWithResult<A, I, R, Success, SuccessEncoded, Failure, FailureEncoded, ResultR>
extends Serializable<A, I, R>,
WithResult<Success, SuccessEncoded, Failure, FailureEncoded, ResultR> {}
Added in v0.67.0
SerializableWithResult (namespace)
Added in v0.67.0
All (type alias)
Signature
export type All = Any | SerializableWithResult<any, any, any, any, any, never, never, unknown>
Added in v0.69.0
Any (type alias)
Signature
export type Any = SerializableWithResult<any, any, any, any, any, any, any, unknown>
Added in v0.69.0
Context (type alias)
Signature
export type Context<P> =
P extends SerializableWithResult<infer _S, infer _SI, infer SR, infer _A, infer _AI, infer _E, infer _EI, infer RR>
? SR | RR
: never
Added in v0.69.0
WithResult (interface)
The WithResult
trait is designed to encapsulate the outcome of an operation, distinguishing between success and failure cases. Each case is associated with a schema that defines the structure and types of the success or failure data.
Signature
export interface WithResult<Success, SuccessEncoded, Failure, FailureEncoded, ResultR> {
readonly [symbolResult]: {
readonly success: Schema.Schema<Success, SuccessEncoded, ResultR>
readonly failure: Schema.Schema<Failure, FailureEncoded, ResultR>
}
}
Added in v0.67.0
WithResult (namespace)
Added in v0.67.0
All (type alias)
Signature
export type All = Any | WithResult<any, any, never, never, unknown>
Added in v0.69.0
Any (type alias)
Signature
export type Any = WithResult<any, any, any, any, unknown>
Added in v0.69.0
Context (type alias)
Signature
export type Context<T> = T extends WithResult<infer _SA, infer _SI, infer _FA, infer _FI, infer R> ? R : never
Added in v0.67.0
Failure (type alias)
Signature
export type Failure<T> = T extends WithResult<infer _A, infer _I, infer _E, infer _EI, infer _R> ? _E : never
Added in v0.69.0
FailureEncoded (type alias)
Signature
export type FailureEncoded<T> = T extends WithResult<infer _A, infer _I, infer _E, infer _EI, infer _R> ? _EI : never
Added in v0.69.0
Success (type alias)
Signature
export type Success<T> = T extends WithResult<infer _A, infer _I, infer _E, infer _EI, infer _R> ? _A : never
Added in v0.68.16
SuccessEncoded (type alias)
Signature
export type SuccessEncoded<T> = T extends WithResult<infer _A, infer _I, infer _E, infer _EI, infer _R> ? _I : never
Added in v0.69.0
symbol
symbol
Signature
export declare const symbol: typeof symbol
Added in v0.67.0
symbolResult
Signature
export declare const symbolResult: typeof symbolResult
Added in v0.67.0
utils
asSerializable
Signature
export declare const asSerializable: <S extends Serializable.All>(
serializable: S
) => Serializable<Serializable.Type<S>, Serializable.Encoded<S>, Serializable.Context<S>>
Added in v0.69.0
asSerializableWithResult
Signature
export declare const asSerializableWithResult: <SWR extends SerializableWithResult.All>(
procedure: SWR
) => SerializableWithResult<
Serializable.Type<SWR>,
Serializable.Encoded<SWR>,
Serializable.Context<SWR>,
WithResult.Success<SWR>,
WithResult.SuccessEncoded<SWR>,
WithResult.Failure<SWR>,
WithResult.FailureEncoded<SWR>,
WithResult.Context<SWR>
>
Added in v0.69.0
asWithResult
Signature
export declare const asWithResult: <WR extends WithResult.All>(
withExit: WR
) => WithResult<
WithResult.Success<WR>,
WithResult.SuccessEncoded<WR>,
WithResult.Failure<WR>,
WithResult.FailureEncoded<WR>,
WithResult.Context<WR>
>
Added in v0.69.0