1
0
mirror of https://github.com/danog/byte-stream.git synced 2024-12-02 09:17:50 +01:00
byte-stream/lib/Stream.php

49 lines
1.0 KiB
PHP
Raw Normal View History

2016-08-18 18:00:38 +02:00
<?php declare(strict_types = 1);
2016-08-16 23:23:46 +02:00
2016-08-10 23:48:42 +02:00
namespace Amp\Stream;
2016-08-16 00:19:32 +02:00
use Interop\Async\Awaitable;
2016-08-10 23:48:42 +02:00
interface Stream {
/**
* Determines if the stream is readable.
*
* @return bool
*/
2016-08-16 00:19:32 +02:00
public function isReadable(): bool;
2016-08-10 23:48:42 +02:00
/**
* Determines if the stream is writable.
*
* @return bool
*/
2016-08-16 00:19:32 +02:00
public function isWritable(): bool;
2016-08-10 23:48:42 +02:00
/**
* @param int|null $bytes
* @param string|null $delimiter
*
* @return \Interop\Async\Awaitable<string> Resolves with bytes read from the stream.
*/
2016-08-16 00:19:32 +02:00
public function read(int $bytes = null, string $delimiter = null): Awaitable;
2016-08-10 23:48:42 +02:00
/**
* @param string $data
*
* @return \Interop\Async\Awaitable<int>
*/
2016-08-16 00:19:32 +02:00
public function write(string $data): Awaitable;
2016-08-10 23:48:42 +02:00
/**
* @param string $data
*
* @return \Interop\Async\Awaitable<int>
*/
2016-08-16 00:19:32 +02:00
public function end(string $data = ''): Awaitable;
2016-08-10 23:48:42 +02:00
/**
* Closes the stream and fails any pending reads or writes.
*/
public function close();
}