Files

27 lines
1.1 KiB
TypeScript
Raw Permalink Normal View History

import type * as plugins from '../plugins.js';
/**
* Abstract transport for communicating with a Rust process.
* Both stdio and socket transports implement this interface.
*
* Events emitted:
* - 'line' (line: string) a complete newline-terminated JSON line received
* - 'error' (err: Error) transport-level error
* - 'close' (...args: any[]) transport has closed/disconnected
* - 'stderr' (line: string) stderr output (stdio transport only)
* - 'reconnected' () transport reconnected after unexpected disconnect (socket only)
*/
export interface IRustTransport extends plugins.events.EventEmitter {
/** Connect the transport (spawn process or connect to socket). Resolves when I/O channel is open. */
connect(): Promise<void>;
/** Write a string to the transport. Handles backpressure. */
write(data: string): Promise<void>;
/** Disconnect the transport. For stdio: kills the process. For socket: closes the connection. */
disconnect(): void;
/** Whether the transport is currently connected and writable. */
readonly connected: boolean;
}