import { Uint8ArrayList } from 'uint8arraylist'; import type { Direction, Stream, StreamStat } from '@libp2p/interface-connection'; import type { Source } from 'it-stream-types'; export interface AbstractStreamInit { /** * A unique identifier for this stream */ id: string; /** * The stream direction */ direction: Direction; /** * The maximum allowable data size, any data larger than this will be * chunked and sent in multiple data messages */ maxDataSize: number; /** * User specific stream metadata */ metadata?: Record; /** * Invoked when the stream ends */ onEnd?: (err?: Error | undefined) => void; } export declare abstract class AbstractStream implements Stream { id: string; stat: StreamStat; metadata: Record; source: AsyncGenerator; private readonly abortController; private readonly resetController; private readonly closeController; private sourceEnded; private sinkEnded; private sinkSunk; private endErr; private readonly streamSource; private readonly onEnd?; private readonly maxDataSize; constructor(init: AbstractStreamInit); protected onSourceEnd(err?: Error): void; protected onSinkEnd(err?: Error): void; close(): void; closeRead(): void; closeWrite(): void; abort(err: Error): void; reset(): void; sink(source: Source): Promise; /** * When an extending class reads data from it's implementation-specific source, * call this method to allow the stream consumer to read the data. */ sourcePush(data: Uint8ArrayList): void; /** * Returns the amount of unread data - can be used to prevent large amounts of * data building up when the stream consumer is too slow. */ sourceReadableLength(): number; /** * Send a message to the remote muxer informing them a new stream is being * opened */ abstract sendNewStream(): void | Promise; /** * Send a data message to the remote muxer */ abstract sendData(buf: Uint8ArrayList): void | Promise; /** * Send a reset message to the remote muxer */ abstract sendReset(): void | Promise; /** * Send a message to the remote muxer, informing them no more data messages * will be sent by this end of the stream */ abstract sendCloseWrite(): void | Promise; /** * Send a message to the remote muxer, informing them no more data messages * will be read by this end of the stream */ abstract sendCloseRead(): void | Promise; } //# sourceMappingURL=stream.d.ts.map