moebius / streams
事件驱动的异步数据流API
1.0.0
2022-06-27 23:20 UTC
Requires
- charm/testing: ^1.1
- moebius/coroutine: ^1.0
- moebius/events: ^1.0
- psr/http-message: ^1.0
This package is not auto-updated.
Last update: 2024-09-18 08:28:31 UTC
README
提供一个强大的API,用于生成符合PSR-7规范的流。
允许将可写流连接到可读流。当写入可写流时,可读流可以被读取,反之亦然。
Moebius\Streams\SourceInterface
表示来自任何来源的字节流。
SourceInterface::write(string $chunk)
将一块字节添加到字节流中。如果任何读者请求字节流暂停,则函数将阻塞。
SourceInterface::end()
表示字节流已完成,并在被ReadableStream消费时被解释为文件末尾。
Moebius\Streams\ReadableStream
类实现了 Psr\Http\Message\StreamInterface
,并提供对数据流的读取访问。
Moebius\Stream\WritableStream
类实现了 Psr\Http\Message\StreamInterface
,并提供对数据流的写入访问。