import { default as Long } from 'long'; /** * Mapping of TL object names to writer functions. */ export type TlWriterMap = Record void> & { _bare?: Record void>; _staticSize: Record; }; /** * Counter of the required number of bytes to encode a given object. * * Used as a pre-pass before using {@link TlBinaryWriter} * to avoid unnecessary allocations. */ export declare class TlSerializationCounter { readonly objectMap: TlWriterMap; count: number; /** * @param objectMap Writers map */ constructor(objectMap: TlWriterMap); /** * Count bytes required to serialize the given object. * * @param objectMap Writers map * @param obj Object to count bytes for */ static countNeededBytes(objectMap: TlWriterMap, obj: { _: string; }): number; /** * Count overhead in bytes for the given number of bytes when * encoded as `bytes` TL type. * * @param size Number of bytes */ static countBytesOverhead(size: number): number; boolean(): void; double(): void; float(): void; int128(): void; int256(): void; int(): void; uint(): void; int53(): void; long(): void; null(): void; raw(val: Uint8Array): void; bytes(val: Uint8Array): void; string(val: string): void; object(obj: { _: string; }): void; vector(fn: (item: unknown) => void, items: unknown[]): void; } /** * Writer for TL objects. */ export declare class TlBinaryWriter { readonly objectMap: TlWriterMap | undefined; readonly dataView: DataView; readonly uint8View: Uint8Array; /** * Current position in the buffer. */ pos: number; /** * @param objectMap Writers map * @param buffer Buffer to write to * @param start Position to start writing at */ constructor(objectMap: TlWriterMap | undefined, data: ArrayBuffer, start?: number); /** * Create a new writer with the given size. * * @param objectMap Writers map * @param size Size of the writer's buffer */ static alloc(objectMap: TlWriterMap | undefined, size: number): TlBinaryWriter; /** * Create a new writer without objects map for manual usage * * @param buffer Buffer to write to, or its size * @param start Position to start writing at */ static manual(buffer: ArrayBuffer | number, start?: number): TlBinaryWriter; /** * Serialize a single object * * @param objectMap Writers map * @param obj Object to serialize * @param knownSize In case the size is known, pass it here */ static serializeObject(objectMap: TlWriterMap, obj: { _: string; }, knownSize?: number): Uint8Array; int(val: number): void; uint(val: number): void; int53(val: number): void; null(): void; long(val: Long): void; float(val: number): void; double(val: number): void; boolean(val: boolean): void; /** * Write raw bytes to the buffer * @param val Buffer to write */ raw(val: Uint8Array): void; int128(val: Uint8Array): void; int256(val: Uint8Array): void; bytes(val: Uint8Array): void; string(val: string): void; object(obj: any): void; vector(fn: (item: unknown, bare?: boolean) => void, val: unknown[], bare?: boolean): void; /** * Get the resulting buffer */ result(): Uint8Array; }