HH\Lib\IO\MemoryHandle
Read from/write to an in-memory buffer
This class is intended for use in unit tests.
Interface Synopsis
namespace HH\Lib\IO;
final class MemoryHandle implements CloseableSeekableReadWriteHandle {...}
Public Methods
->__construct(string $buffer = '', MemoryHandleWriteMode $writeMode = MemoryHandleWriteMode::OVERWRITE)
->appendToBuffer(string $data): void
Append data to the internal buffer, preserving position->close(): void
->closeWhenDisposed(): \IDisposable
->getBuffer(): string
->readAllowPartialSuccessAsync(?int $max_bytes = NULL, ?int $_timeout_nanos = NULL): Awaitable<string>
->readImpl(?int $max_bytes = NULL): string
->reset(string $data = ''): void
Set the internal buffer and reset position to the beginning of the file->seek(int $pos): void
->tell(): int
->writeAllowPartialSuccessAsync(string $data, ?int $timeout_nanos = NULL): Awaitable<int>
Public Methods (HH\Lib\IO\WriteHandle
)
->writeAllAsync(string $bytes, ?int $timeout_ns = NULL): Awaitable<void>
Write all of the requested data
Public Methods (HH\Lib\IO\ReadHandle
)
->readAllAsync(?int $max_bytes = NULL, ?int $timeout_ns = NULL): Awaitable<string>
Read until there is no more data to read->readFixedSizeAsync(int $size, ?int $timeout_ns = NULL): Awaitable<string>
Read a fixed amount of data