timedpipe

package
v0.0.0-...-ab7dfd3 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pipe

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

func New

func New(options ...PipeOption) *Pipe

New creates a new instance of Pipe with the provided options.

The options parameter is variadic and allows for configuration of the Pipe. It accepts zero or more PipeOption values.

The function returns a pointer to the created Pipe.

func (*Pipe) GetReadData

func (t *Pipe) GetReadData() map[time.Duration][]byte

GetReadData returns the map of bytes read from the pipe, indexed by time duration.

It does not take any parameters. It returns a map of time duration to a slice of bytes.

func (*Pipe) GetWriteData

func (t *Pipe) GetWriteData() map[time.Duration][]byte

GetWriteData returns the data to be written by the Pipe.

It returns a map with time durations as keys and byte slices as values.

func (*Pipe) Read

func (t *Pipe) Read(p []byte) (n int, err error)

Read reads data from the input into the given byte slice. Storing the time passed since the start time of the pipe

It returns the number of bytes read and any error encountered.

func (*Pipe) SetInput

func (t *Pipe) SetInput(r io.Reader) *Pipe

SetInput assigns an input reader to the Pipe.

r - the input reader to be assigned. Returns the modified Pipe.

func (*Pipe) SetOutput

func (t *Pipe) SetOutput(w io.Writer) *Pipe

SetOutput sets the output for the Pipe.

It takes a parameter `w` of type `io.Writer` and returns a pointer to `Pipe`.

func (*Pipe) SetStartTime

func (t *Pipe) SetStartTime(time time.Time) *Pipe

SetStartTime sets the start time of the Pipe.

time - the time to set as the start time. Returns a pointer to the Pipe.

func (*Pipe) Write

func (t *Pipe) Write(p []byte) (n int, err error)

Write writes the given byte slice to the Pipe. Storing data and the time passed since the start time of the Pipe.

It takes a parameter p which is a byte slice. It returns the number of bytes written and an error, if any.

type PipeOption

type PipeOption func(*Pipe)

func SetStartTime

func SetStartTime(time time.Time) PipeOption

SetStartTime sets the start time of the Pipe.

time: the start time to set. Returns: a PipeOption function.

func StartNow

func StartNow() PipeOption

StartNow returns a PipeOption function that sets the start time of the Pipe to the current time.

It takes no parameters and returns a PipeOption.

func WithInput

func WithInput(r io.Reader) PipeOption

WithInput returns a PipeOption function that sets the input of a Pipe.

r is the input reader. PipeOption is a function that modifies a Pipe.

func WithOutput

func WithOutput(w io.Writer) PipeOption

WithOutput sets the output writer for the Pipe.

w: the output writer to set. Returns: a PipeOption function.

Jump to

Keyboard shortcuts

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