chanio

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package chanio provides a way to use channels as io.Reader and io.Writer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChanReader

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

Read implements io.Reader.

Use NewChanReader to obtain a new ChanReader.

func NewChanReader

func NewChanReader(ch <-chan []byte) (*ChanReader, error)

NewChanReader returns a new ChanReader reading from ch. The provided channel must not be nil.

func (*ChanReader) Read

func (r *ChanReader) Read(bytes []byte) (int, error)

Read reads up to len(bytes) bytes into bytes. It returns the number of bytes read and any error encountered.

type ChanWriter

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

Write implements io.Writer.

Use NewChanWriter to obtain a new ChanWriter.

func NewChanWriter

func NewChanWriter(ch chan<- []byte) (*ChanWriter, error)

NewChanWriter returns a new ChanWriter writing to ch. The provided channel must not be nil.

func (*ChanWriter) Write

func (w *ChanWriter) Write(bytes []byte) (int, error)

Write writes len(bytes) bytes from bytes to the underlying data stream. It returns the number of bytes written from bytes and any error encountered that caused the write to stop early.

Jump to

Keyboard shortcuts

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