Documentation

Std.Http.Data.Body.Stream

Body.Stream #

This module defines a zero-buffer rendezvous body channel (Body.Stream) that supports both sending and receiving chunks.

There is no queue and no capacity. A send waits for a receiver and a receive waits for a sender. At most one blocked producer and one blocked consumer are supported.

A zero-buffer rendezvous body channel that supports both sending and receiving chunks.

Instances For

    Creates a rendezvous body stream.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      Attempts to receive a chunk from the channel without blocking. Returns some chunk only when a producer is already waiting.

      Equations
      Instances For

        Non-blocking receive for the Body typeclass. Returns none when no producer is waiting and the channel is still open, some (some chunk) when data is ready, or some none at end-of-stream (channel closed with no pending producer).

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          Receives a chunk from the channel. Blocks until a producer sends one. Returns none if the channel is closed and no producer is waiting.

          Equations
          Instances For
            @[inline]

            Checks whether the channel is closed.

            Equations
            Instances For
              @[inline]

              Gets the known size if available.

              Equations
              Instances For
                @[inline]

                Sets known size metadata.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For

                  Creates a selector that resolves when a producer is waiting (or the channel closes).

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    @[inline]
                    def Std.Http.Body.Stream.forIn {β : Type} (stream : Stream) (acc : β) (step : ChunkβAsync.Async (ForInStep β)) :

                    Iterates over chunks until the channel closes.

                    Equations
                    Instances For
                      @[inline]
                      def Std.Http.Body.Stream.forIn' {β : Type} (stream : Stream) (acc : β) (step : ChunkβAsync.ContextAsync (ForInStep β)) :

                      Context-aware iteration over chunks until the channel closes.

                      Equations
                      Instances For

                        Abstracts over how the next chunk is received, allowing readAll to work in both Async (no cancellation) and ContextAsync (races with cancellation via doneSelector).

                        • nextChunk : Streamm (Option Chunk)

                          Receives the next chunk, stopping at EOF or (in ContextAsync) when the context is cancelled.

                        Instances
                          @[implicit_reducible]
                          Equations
                          • One or more equations did not get rendered due to their size.
                          def Std.Http.Body.Stream.readAll {α : Type} {m : TypeType} [FromByteArray α] [Monad m] [MonadExceptOf IO.Error m] [NextChunk m] (stream : Stream) (maximumSize : Option UInt64 := none) :
                          m α

                          Reads all remaining chunks and decodes them into α.

                          Works in both Async (reads until EOF, no cancellation) and ContextAsync (also stops if the context is cancelled).

                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For
                            def Std.Http.Body.Stream.send (stream : Stream) (chunk : Chunk) (incomplete : Bool := false) :

                            Sends a chunk.

                            If incomplete := true, the chunk is buffered and collapsed with subsequent chunks, and is not delivered to the receiver yet. If incomplete := false, any buffered incomplete pieces are collapsed with this chunk and the single merged chunk is sent.

                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For

                              Returns true when a consumer is currently blocked waiting for data.

                              Equations
                              Instances For

                                Creates a selector that resolves when consumer interest is present. Returns true when a consumer is waiting, false when the channel closes first.

                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For

                                  Creates a body from a producer function. Returns the stream immediately and runs gen in a detached task. The channel is always closed when gen returns or throws. Errors from gen are not rethrown here; consumers observe end-of-stream via recv = none.

                                  Equations
                                  Instances For

                                    Creates a body from a fixed byte array.

                                    Equations
                                    • One or more equations did not get rendered due to their size.
                                    Instances For

                                      Creates an empty Stream body channel (already closed, no data).

                                      Prefer Body.Empty when you need a concrete zero-cost type. Use this when the calling context requires a Stream specifically.

                                      Equations
                                      Instances For
                                        @[implicit_reducible]
                                        Equations
                                        • One or more equations did not get rendered due to their size.
                                        @[implicit_reducible]
                                        Equations
                                        • One or more equations did not get rendered due to their size.
                                        @[implicit_reducible]
                                        Equations
                                        • One or more equations did not get rendered due to their size.
                                        @[implicit_reducible]
                                        Equations
                                        • One or more equations did not get rendered due to their size.

                                        Builds a request with a streaming body generator.

                                        Equations
                                        Instances For

                                          Builds a response with a streaming body generator.

                                          Equations
                                          Instances For