contextio

package
v0.48.3 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package contextio provides io decorators that are context-aware.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCloser

func NewCloser(ctx context.Context, c io.Closer) io.Closer

NewCloser wraps an io.Reader to handle context cancellation.

The underlying io.Closer is closed even if the context is done.

func NewReader

func NewReader(ctx context.Context, r io.Reader) io.Reader

NewReader wraps an io.Reader to handle context cancellation.

Context state is checked BEFORE every Read.

If r implements io.ReadCloser, the returned reader will also implement io.ReadCloser.

func NewWriter

func NewWriter(ctx context.Context, w io.Writer) io.Writer

NewWriter wraps an io.Writer to handle context cancellation.

Context state is checked BEFORE every Write.

The returned Writer also implements io.ReaderFrom to allow io.Copy to select the best strategy while still checking the context state before every chunk transfer.

If w implements io.WriteCloser, the returned Writer will also implement io.WriteCloser.

Types

This section is empty.

Jump to

Keyboard shortcuts

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