import { CborObj } from "../CborObj/CborObj.js"; import { SubCborRef } from "../SubCborRef.js"; /** * @deprecated use `ToCborString` interface instead */ export interface CBORSerializable { toCBOR: () => Uint8Array; } export interface ToCborObj { toCborObj: () => CborObj; } export interface ToCborString { toCbor: () => Uint8Array; } export interface ToCborBytes { /** * usually same result as `this.toCbor().toBytes()` * * but if `this` remembers a `SubCborRef` object, * it can be uset to shortcut the process and just return the bytes **/ toCborBytes: () => Uint8Array; } export interface ToCbor extends ToCborObj, ToCborString, ToCborBytes { /** * strictly require `SubCborRef` property to classes that want to implement `ToCbor` * * if this is not desired, implement `ToCborString` and `ToCborObj` together to omit this requirement **/ readonly cborRef: SubCborRef | undefined; } export interface FromCbor { fromCbor(cbor: Uint8Array | string): T; fromCborObj(cbor: CborObj): T; }