cache

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2021 License: MIT Imports: 3 Imported by: 1

Documentation

Overview

Package cache includes a struct for caching reads.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	Reader   io.ByteReadCloser
	Cursor   int
	Complete *bool
	Content  *[]byte
}

func NewCache

func NewCache(r io.ByteReadCloser) *Cache

func NewCacheWithContent

func NewCacheWithContent(r io.ByteReadCloser, c *[]byte, i int) *Cache

func (*Cache) Close

func (c *Cache) Close() error

func (*Cache) Read

func (c *Cache) Read(p []byte) (n int, err error)

Read reads a maximum len(p) bytes from the reader and returns an error, if any.

func (*Cache) ReadAll

func (c *Cache) ReadAll() ([]byte, error)

ReadAll reads all content from the underlying reader and returns the content

func (*Cache) ReadAllAndClose

func (c *Cache) ReadAllAndClose() ([]byte, error)

func (*Cache) ReadAt

func (c *Cache) ReadAt(i int) (byte, error)

ReadAt returns the byte at the index given by i

func (*Cache) ReadByte

func (c *Cache) ReadByte() (byte, error)

func (*Cache) ReadBytes

func (c *Cache) ReadBytes(delim byte) ([]byte, error)

func (*Cache) ReadFirst

func (c *Cache) ReadFirst() (byte, error)

ReadFirst returns the first byte stating at the cursor.

func (*Cache) ReadRange

func (c *Cache) ReadRange(start int, end int) ([]byte, error)

ReadRange reads a range of btes from the cache. End points to the index of the last byte to read, so [start:end+1]

func (*Cache) ReadString

func (c *Cache) ReadString(delim byte) (string, error)

Jump to

Keyboard shortcuts

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