public function pipe(Context $context, WritableStream $stream, bool $close = false): Promise
    {
        return $context->task(function (Context $context) use ($stream, $close) {
            $len = 0;
            
            try {
                while (null != ($chunk = yield $this->read($context, 0xFFFF))) {
                    $len += yield $stream->write($context, $chunk);
                }
            } finally {
                $this->close();
                
                if ($close) {
                    $stream->close();
                }
            }
            
            return $len;
        });
    }