Skip to content

You're viewing documentation for a pre-release version. View the latest stable version

Structure

BufferedMultipartWriter

A MultipartWriter that buffers data up to a specified capacity before forwarding to an underlying writer.
struct BufferedMultipartWriter<UnderlyingWriter> where UnderlyingWriter : MultipartWriter

Overview

This writer acts as a buffer between your application and another writer implementation, helping to optimize memory usage and improve performance when dealing with large multipart messages. It accumulates data until a threshold is reached, then forwards the buffered content to the underlying writer and clears its internal buffer.

// Example: Create a buffered writer with 8KB capacity that writes to a socket
var writer = BufferedMultipartWriter(
    boundary: "boundary123",
    bufferCapacity: 8192,
    underlyingWriter: SocketMultipartWriter(socket: mySocket)
)

// Use the writer as normal - buffering happens automatically
try await writer.writePart(myPart)
try await writer.finish()

Topics

Initializers

Instance Properties

Instance Methods

Type Aliases

  • typealias Failure
    This writer only throws errors that originate from the underlying writer.
  • typealias OutboundBody
    The body type of the underlying writer, which this writer buffers into before forwarding.

Relationships

Conforms To