1
0
mirror of https://github.com/danog/byte-stream.git synced 2024-12-04 02:07:49 +01:00
byte-stream/lib/Stream.php
2016-12-29 23:09:06 -06:00

49 lines
1016 B
PHP

<?php
namespace Amp\Stream;
use Interop\Async\Promise;
interface Stream {
/**
* Determines if the stream is readable.
*
* @return bool
*/
public function isReadable(): bool;
/**
* Determines if the stream is writable.
*
* @return bool
*/
public function isWritable(): bool;
/**
* @param int|null $bytes
* @param string|null $delimiter
*
* @return \Interop\Async\Promise<string> Resolves with bytes read from the stream.
*/
public function read(int $bytes = null, string $delimiter = null): Promise;
/**
* @param string $data
*
* @return \Interop\Async\Promise<int>
*/
public function write(string $data): Promise;
/**
* @param string $data
*
* @return \Interop\Async\Promise<int>
*/
public function end(string $data = ''): Promise;
/**
* Closes the stream and fails any pending reads or writes.
*/
public function close();
}