/** * Protobuf size calculation utilities for DAG-PB nodes. * * Computes exact serialized sizes matching @ipld/dag-pb's encoding * without allocating byte arrays. Used by DirFlat to avoid O(N) * re-serialization on every file insert. * * Ported from @ipld/dag-pb/src/pb-encode.js (sov, len64, sizeLink, sizeNode) * and boxo's directory.go estimatedSize logic. */ import type { Mtime } from 'ipfs-unixfs'; /** * Protobuf varint byte size, matching @ipld/dag-pb's sov(). */ export declare function varintLen(x: number): number; /** * Compute UTF-8 byte length of a JS string without allocation. * * Safe to assume UTF-8 because @ipld/dag-pb always encodes PBLink.Name * via TextEncoder (UTF-8) and decodes via TextDecoder (UTF-8). * This produces the same result as textEncoder.encode(str).length * without the Uint8Array allocation on every put() call. */ export declare function utf8ByteLength(str: string): number; /** * Exact bytes a single PBLink adds to the PBNode encoding. * * Matches sizeLink() + its wrapper in sizeNode() from pb-encode.js: * linkLen = Hash(1+sov(cidLen)+cidLen) + Name(1+sov(nameLen)+nameLen) + Tsize(1+sov(tsize)) * total = 1 + sov(linkLen) + linkLen */ export declare function linkSerializedSize(nameByteLen: number, cidByteLength: number, tsize: number): number; /** * Exact bytes the PBNode Data field adds for a UnixFS directory. * * Directory-only: the type field is hardcoded to directory (2 bytes) and * the default mode is 0o755. Do not use for file nodes (different type * byte, different default mode 0o644). * * For the common case (no mode, no mtime) this is always 4 bytes: * innerSize=2 [0x08,0x01], wrapper 1+1+2=4. */ export declare function dataFieldSerializedSize(mode?: number, mtime?: Mtime): number; //# sourceMappingURL=pb-size.d.ts.map