import type { RecordType } from '../types.cjs'; export interface RustResolveOptions { /** Hard deadline in milliseconds. Rust task self-cancels at the * boundary; prevents orphan tasks if the JS caller's watchdog gives * up first. `| undefined` is explicit so callers can spread * `{ timeoutMs: options?.timeout }` under exactOptionalPropertyTypes. */ timeoutMs?: number | undefined; } export interface RustMxRecord { exchange: string; priority: number; } export interface RustSrvRecord { priority: number; weight: number; port: number; name: string; } export interface RustSoaRecord { nsname: string; hostmaster: string; serial: number; refresh: number; retry: number; expire: number; minttl: number; } export interface RustCaaRecord { /** 128 when issuer-critical bit set, 0 otherwise (mirrors node:dns). */ critical: number; issue?: string; issuewild?: string; iodef?: string; contactemail?: string; contactphone?: string; } export interface RustNaptrRecord { order: number; preference: number; flags: string; service: string; regexp: string; replacement: string; } /** TLSA. Note: field is `matching` (not `match`); the validator-side * adapter renames if needed for the public TS type. */ export interface RustTlsaRecord { certUsage: number; selector: number; matching: number; data: Uint8Array; } /** Rust's field-complete representation of node:dns's tagged ANY union. * Only the fields appropriate for `type` are populated. */ export interface RustAnyRecord { type: RecordType; address?: string; ttl?: number; value?: string; exchange?: string; priority?: number; order?: number; preference?: number; flags?: string; service?: string; regexp?: string; replacement?: string; nsname?: string; hostmaster?: string; serial?: number; refresh?: number; retry?: number; expire?: number; minttl?: number; weight?: number; port?: number; name?: string; certUsage?: number; selector?: number; matching?: number; data?: Uint8Array; entries?: string[]; critical?: number; issue?: string; issuewild?: string; iodef?: string; contactemail?: string; contactphone?: string; } export declare const RUST_BINDING_INTERFACE_VERSION: 1; export interface RustBinding { resolveMx(hostname: string, options?: RustResolveOptions | null): Promise; /** Resolve MX for many hostnames in one FFI call. `out[i]` ↔ `hostnames[i]`; * a per-host failure yields `[]` for that slot. The whole batch rejects * at one absolute Rust-side deadline so abandoned waves cannot outlive * the JavaScript caller. */ resolveMxBatch(hostnames: string[], options?: RustResolveOptions | null): Promise; resolveA(hostname: string, options?: RustResolveOptions | null): Promise; resolveAaaa(hostname: string, options?: RustResolveOptions | null): Promise; resolveCname(hostname: string, options?: RustResolveOptions | null): Promise; resolveTxt(hostname: string, options?: RustResolveOptions | null): Promise; resolveNs(hostname: string, options?: RustResolveOptions | null): Promise; resolvePtr(hostname: string, options?: RustResolveOptions | null): Promise; resolveSrv(hostname: string, options?: RustResolveOptions | null): Promise; resolveSoa(hostname: string, options?: RustResolveOptions | null): Promise; resolveCaa(hostname: string, options?: RustResolveOptions | null): Promise; resolveNaptr(hostname: string, options?: RustResolveOptions | null): Promise; resolveTlsa(hostname: string, options?: RustResolveOptions | null): Promise; resolveAny(hostname: string, options?: RustResolveOptions | null): Promise; reverseLookup(ip: string, options?: RustResolveOptions | null): Promise; bindingInterfaceVersion(): number; buildInfo(): string; } export type RustBindingInspection = { compatible: true; binding: RustBinding; } | { compatible: false; reason: string; cause?: unknown; }; /** Inspect the complete native surface and retain why an addon is stale. */ export declare function inspectRustBinding(value: unknown): RustBindingInspection; /** Boolean compatibility wrapper retained for callers and focused tests. */ export declare function isRustBinding(value: unknown): value is RustBinding; export type NativeBindingLoadErrorCode = 'ERR_ZYNOR_NATIVE_LOADER_INIT' | 'ERR_ZYNOR_NATIVE_UNSUPPORTED_PLATFORM' | 'ERR_ZYNOR_NATIVE_BINDING_NOT_FOUND' | 'ERR_ZYNOR_NATIVE_BINDING_LOAD' | 'ERR_ZYNOR_NATIVE_BINDING_INTERFACE'; export interface RustBindingLoadAttempt { target: string; kind: 'file' | 'package'; outcome: 'missing' | 'load-error' | 'interface-error'; detail: string; cause?: unknown; } export declare class NativeBindingLoadError extends Error { readonly code: NativeBindingLoadErrorCode; readonly attempts: readonly RustBindingLoadAttempt[]; readonly platform: string; readonly arch: string; readonly nodeVersion: string; readonly modulesAbi: string; constructor(code: NativeBindingLoadErrorCode, message: string, environment: RustBindingLoaderEnvironment, attempts?: readonly RustBindingLoadAttempt[], cause?: unknown); } export interface RustBindingCandidate { target: string; kind: 'file' | 'package'; /** Build-embedded integrity metadata for a staged file candidate. */ integrity?: { sha256: string; byteLength: number; }; } export interface RustBindingLoaderEnvironment { platform: string; arch: string; nodeVersion: string; modulesAbi: string; platformSupported: boolean; } export interface RustBindingLoaderRuntime { require: NodeJS.Require; exists: (path: string) => boolean; readFile?: (path: string) => Uint8Array; candidates: readonly RustBindingCandidate[]; environment: RustBindingLoaderEnvironment; } /** * Testable candidate loader. It resolves optional packages before requiring * them, so a genuinely absent prebuild is distinguishable from a transitive * MODULE_NOT_FOUND or ABI failure inside an installed addon. */ export declare function loadRustBindingCandidates(runtime: RustBindingLoaderRuntime): RustBinding; /** * Lazy accessor for the Rust binding. The `.node` file is loaded on the * first call; subsequent calls return the cached result or throw the same * diagnostic object. A load/ABI/interface failure retains its original cause. * * The `'zynor'` main entry never calls this. Only the `'zynor/native'` * subpath (via its Rust-backed NativeProvider) triggers the load. */ export declare function getRustNative(): RustBinding;