bufferwriter

package
v3.71.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2024 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package bufferwritter provides a contentWriter implementation using a shared buffer pool for memory management.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BufferWriter

type BufferWriter struct {
	// contains filtered or unexported fields
}

BufferWriter implements contentWriter, using a shared buffer pool for memory management.

func New

func New(ctx context.Context) *BufferWriter

New creates a new instance of BufferWriter.

func (*BufferWriter) CloseForWriting

func (b *BufferWriter) CloseForWriting() error

CloseForWriting is a no-op for buffer, as there is no resource cleanup needed for bytes.Buffer.

func (*BufferWriter) Len

func (b *BufferWriter) Len() int

Len returns the length of the buffer's content.

func (*BufferWriter) ReadCloser

func (b *BufferWriter) ReadCloser() (io.ReadCloser, error)

ReadCloser provides a read-closer for the buffer's content. It wraps the buffer's content in a NopCloser to provide a ReadCloser without additional closing behavior, as closing a bytes.Buffer is a no-op.

func (*BufferWriter) String

func (b *BufferWriter) String() (string, error)

String returns the buffer's content as a string.

func (*BufferWriter) Write

func (b *BufferWriter) Write(ctx context.Context, data []byte) (int, error)

Write delegates the writing operation to the underlying bytes.Buffer, ignoring the context. The context is included to satisfy the contentWriter interface, allowing for future extensions where context handling might be necessary (e.g., for timeouts or cancellation).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL