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

49 lines
1016 B
PHP
Raw Normal View History

2016-12-30 06:09:06 +01:00
<?php
2016-08-16 23:23:46 +02:00
2016-08-10 23:48:42 +02:00
namespace Amp\Stream;
use AsyncInterop\Promise;
2016-08-16 00:19:32 +02:00
interface ByteStream {
2016-08-10 23:48:42 +02:00
/**
* 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 \AsyncInterop\Promise<string> Resolves with bytes read from the stream.
2016-08-10 23:48:42 +02:00
*/
2016-11-14 22:05:19 +01:00
public function read(int $bytes = null, string $delimiter = null): Promise;
2016-08-10 23:48:42 +02:00
/**
* @param string $data
*
* @return \AsyncInterop\Promise<int>
2016-08-10 23:48:42 +02:00
*/
2016-11-14 22:05:19 +01:00
public function write(string $data): Promise;
2016-08-10 23:48:42 +02:00
/**
* @param string $data
*
* @return \AsyncInterop\Promise<int>
2016-08-10 23:48:42 +02:00
*/
2016-11-14 22:05:19 +01:00
public function end(string $data = ''): Promise;
2016-08-10 23:48:42 +02:00
/**
* Closes the stream and fails any pending reads or writes.
*/
public function close();
}