UNPKG

1.9 kBTypeScriptView Raw
1import type RAL from './ral';
2import { Message } from './messages';
3export interface FunctionContentEncoder {
4 name: string;
5 encode(input: Uint8Array): Promise<Uint8Array>;
6}
7export interface StreamContentEncoder {
8 name: string;
9 create(): RAL.WritableStream;
10}
11export type ContentEncoder = FunctionContentEncoder | (FunctionContentEncoder & StreamContentEncoder);
12export interface FunctionContentDecoder {
13 name: string;
14 decode(buffer: Uint8Array): Promise<Uint8Array>;
15}
16export interface StreamContentDecoder {
17 name: string;
18 create(): RAL.WritableStream;
19}
20export type ContentDecoder = FunctionContentDecoder | (FunctionContentDecoder & StreamContentDecoder);
21export interface ContentTypeEncoderOptions {
22 charset: RAL.MessageBufferEncoding;
23}
24export interface FunctionContentTypeEncoder {
25 name: string;
26 encode(msg: Message, options: ContentTypeEncoderOptions): Promise<Uint8Array>;
27}
28export interface StreamContentTypeEncoder {
29 name: string;
30 create(options: ContentTypeEncoderOptions): RAL.WritableStream;
31}
32export type ContentTypeEncoder = FunctionContentTypeEncoder | (FunctionContentTypeEncoder & StreamContentTypeEncoder);
33export interface ContentTypeDecoderOptions {
34 charset: RAL.MessageBufferEncoding;
35}
36export interface FunctionContentTypeDecoder {
37 name: string;
38 decode(buffer: Uint8Array, options: ContentTypeDecoderOptions): Promise<Message>;
39}
40export interface StreamContentTypeDecoder {
41 name: string;
42 create(options: ContentTypeDecoderOptions): RAL.WritableStream;
43}
44export type ContentTypeDecoder = FunctionContentTypeDecoder | (FunctionContentTypeDecoder & StreamContentTypeDecoder);
45interface Named {
46 name: string;
47}
48export declare namespace Encodings {
49 function getEncodingHeaderValue(encodings: Named[]): string | undefined;
50 function parseEncodingHeaderValue(value: string): string[];
51}
52export {};