#pragma once #include namespace workerd { kj::Own newNullIoStream(); kj::Own newNullInputStream(); kj::Own newNullOutputStream(); // Get a shared global null output stream (singleton, thread-safe) kj::AsyncOutputStream& getGlobalNullOutputStream(); // When maybeBacking is provided, it is held onto by the MemoryInputStream // using a kj::Rc<...> so that teeing the stream can share ownership of // the backing storage without the need for any additional buffering. If // the backing storage is not provided, then optimized teeing of the stream // will not be supported and the implementation will return a kj::none from // tryTee(). kj::Own newMemoryInputStream( kj::ArrayPtr, kj::Maybe> maybeBacking = kj::none); kj::Own newMemoryInputStream( kj::StringPtr, kj::Maybe> maybeBacking = kj::none); // An InputStream that can be disconnected. class NeuterableInputStream: public kj::AsyncInputStream, public kj::Refcounted { public: virtual void neuter(kj::Exception ex) = 0; }; class NeuterableIoStream: public kj::AsyncIoStream { public: virtual void neuter(kj::Exception ex) = 0; }; // Until kj::AsyncOutputStream has an end() method of its own... We // provide this subclass that adds it. class EndableAsyncOutputStream: public kj::AsyncOutputStream { public: // By default, end() is a no-op. Subclasses may override. virtual kj::Promise end() { co_return; } }; kj::Own newNeuterableInputStream(kj::AsyncInputStream&); kj::Own newNeuterableIoStream(kj::AsyncIoStream&); } // namespace workerd