RpcSerialization.ts overview
Since v1.0.0
Exports Grouped by Category
serialization
Parser (interface)
Signature
export interface Parser {
readonly decode: (data: Uint8Array | string) => ReadonlyArray<unknown>
readonly encode: (response: unknown) => Uint8Array | string | undefined
}
Since v1.0.0
RpcSerialization (class)
Signature
declare class RpcSerialization
Since v1.0.0
json
Signature
declare const json: { unsafeMake(): Parser; readonly contentType: string; readonly includesFraming: boolean }
Since v1.0.0
jsonRpc
Signature
declare const jsonRpc: (options?: { readonly contentType?: string | undefined }) => RpcSerialization["Type"]
Since v1.0.0
layerJson
A rpc serialization layer that uses JSON for serialization.
Use this if your protocol supports framing for messages, otherwise use layerNdjson
.
Signature
declare const layerJson: Layer.Layer<RpcSerialization, never, never>
Since v1.0.0
layerJsonRpc
A rpc serialization layer that uses JSON-RPC for serialization.
Signature
declare const layerJsonRpc: (options?: { readonly contentType?: string | undefined }) => Layer.Layer<RpcSerialization>
Since v1.0.0
layerMsgPack
A rpc serialization layer that uses MessagePack for serialization.
MessagePack has a more compact binary format compared to JSON and NDJSON. It also has better support for binary data.
Signature
declare const layerMsgPack: Layer.Layer<RpcSerialization, never, never>
Since v1.0.0
layerNdJsonRpc
A rpc serialization layer that uses JSON-RPC for serialization seperated by new lines.
Signature
declare const layerNdJsonRpc: (options?: { readonly contentType?: string | undefined }) => Layer.Layer<RpcSerialization>
Since v1.0.0
layerNdjson
A rpc serialization layer that uses NDJSON for serialization.
Use this if your protocol does not support framing for messages, otherwise use layerJson
.
Signature
declare const layerNdjson: Layer.Layer<RpcSerialization, never, never>
Since v1.0.0
msgPack
Signature
declare const msgPack: { unsafeMake(): Parser; readonly contentType: string; readonly includesFraming: boolean }
Since v1.0.0
ndJsonRpc
Signature
declare const ndJsonRpc: (options?: { readonly contentType?: string | undefined }) => RpcSerialization["Type"]
Since v1.0.0
ndjson
Signature
declare const ndjson: { unsafeMake(): Parser; readonly contentType: string; readonly includesFraming: boolean }
Since v1.0.0