LibWeb: Implement ReadableStream.pipeTo()

This commit is contained in:
Kenneth Myhra 2024-04-06 19:02:28 +02:00 committed by Andreas Kling
commit d3b2cd8ab6
Notes: sideshowbarker 2024-07-16 22:18:54 +09:00
3 changed files with 46 additions and 1 deletions

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2024, Kenneth Myhra <kennethmyhra@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -26,6 +27,13 @@ struct ReadableStreamGetReaderOptions {
Optional<Bindings::ReadableStreamReaderMode> mode;
};
struct StreamPipeOptions {
bool prevent_close { false };
bool prevent_abort { false };
bool prevent_cancel { false };
Optional<JS::NonnullGCPtr<DOM::AbortSignal>> signal;
};
struct ReadableStreamPair {
// Define a couple container-like methods so this type may be used as the return type of the IDL `tee` implementation.
size_t size() const { return 2; }
@ -62,6 +70,7 @@ public:
bool locked() const;
WebIDL::ExceptionOr<JS::GCPtr<JS::Object>> cancel(JS::Value reason);
WebIDL::ExceptionOr<ReadableStreamReader> get_reader(ReadableStreamGetReaderOptions const& = {});
WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Object>> pipe_to(WritableStream& destination, StreamPipeOptions const& = {});
WebIDL::ExceptionOr<ReadableStreamPair> tee();
Optional<ReadableStreamController>& controller() { return m_controller; }