import { identityEmbeddedTypeEncode } from "./encoder";
import { genericEmbeddedTypeDecode, ReaderStateOptions } from "./reader";
import { genericEmbeddedTypeEncode, neverEmbeddedTypeEncode } from "./writer";
import { Value } from "./values";
import { DecoderState, neverEmbeddedTypeDecode } from "./decoder";
import type { GenericEmbedded, EmbeddedType, EmbeddedTypeDecode } from "./embedded";

export const genericEmbeddedType: EmbeddedType<GenericEmbedded> =
    Object.assign({},
                  genericEmbeddedTypeDecode,
                  genericEmbeddedTypeEncode);

export const neverEmbeddedType: EmbeddedType<never> =
    Object.assign({},
                  neverEmbeddedTypeDecode,
                  neverEmbeddedTypeEncode);

export const identityEmbeddedTypeDecode: EmbeddedTypeDecode<any> = {
    decode(_s: DecoderState): any {
        throw new Error("Cannot decode identityEmbeddedType");
    },

    fromValue(_v: Value<GenericEmbedded>, _options: ReaderStateOptions): any {
        throw new Error("Cannot decode identityEmbeddedType");
    },
};

export const identityEmbeddedType: EmbeddedType<any> =
    Object.assign({},
                  identityEmbeddedTypeDecode,
                  identityEmbeddedTypeEncode);
