/**
 * This is an abstract class, must be implemented by subclasses
 *
 * @template T
 */
export class Codec {
    /**
     *
     * @param {Uint8Array} data
     * @returns {Promise<T>}
     */
    async decode(data) {
        // need to implement in the subclass
        throw  new Error('Unsupported Operation');
    }

    /**
     * Whether codec is able to decode this data, typically checks headers in the data
     * @param {Uint8Array} data
     * @return {Promise<boolean>} true if able, false otherwise
     */
    async test(data) {
        return true;
    }
}
