From 2e3505bea41552ba28978399cddead52d64d7e85 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Thu, 11 Jul 2024 00:27:55 +0900 Subject: feat: support streaming decoding --- src/Stream/StreamInterface.php | 77 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 src/Stream/StreamInterface.php (limited to 'src/Stream/StreamInterface.php') diff --git a/src/Stream/StreamInterface.php b/src/Stream/StreamInterface.php new file mode 100644 index 0000000..0655d22 --- /dev/null +++ b/src/Stream/StreamInterface.php @@ -0,0 +1,77 @@ + + * An 8-bit unsigned integer read from the stream. + * + * @throws UnexpectedEofException + * Thrown if the stream have reached the end. + * + * @phpstan-impure + */ + public function readByte(): int; + + /** + * Reads a single byte from the stream without advancing the position. + * + * @return int<0, 255> + * An 8-bit unsigned integer read from the stream. + * + * @throws UnexpectedEofException + * Thrown if the stream have reached the end. + * + * @phpstan-impure + */ + public function peekByte(): int; + + /** + * Seeks $bytes bytes from the current position. + * + * @param positive-int $bytes + * + * @throws UnexpectedEofException + * Thrown if the stream does not have enough bytes to seek. + * + * @phpstan-impure + */ + public function seek(int $bytes): void; + + /** + * Returns the current position in the stream. + * + * @return 0|positive-int + * + * @phpstan-impure + */ + public function tell(): int; + + /** + * Returns whether the stream has reached the end. + * + * @phpstan-impure + */ + public function eof(): bool; +} -- cgit v1.2.3-70-g09d2