Stream

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsStreamExhausted

func IsStreamExhausted(err error) bool

IsStreamExhausted checks if the error is a stream exhausted error.

Parameters:

  • err: The error to check.

Returns:

  • bool: True if the error is a stream exhausted error. False otherwise.

Types

type ErrStreamExhausted

type ErrStreamExhausted struct{}

ErrStreamExhausted is the error returned when the stream is exhausted.

func NewStreamExhausted

func NewStreamExhausted() *ErrStreamExhausted

NewStreamExhausted creates a new stream exhausted error.

Returns:

  • *ErrStreamExhausted: The stream exhausted error.

func (*ErrStreamExhausted) Error

func (e *ErrStreamExhausted) Error() string

Error implements the error interface.

Message: "stream is exhausted"

type Stream

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

Stream is a stream of runes.

func NewStream

func NewStream(data []byte) Stream

NewStream creates a new stream.

Parameters:

  • data: The data of the stream.

Returns:

  • Stream: The stream.

func (*Stream) Accept

func (s *Stream) Accept()

Accept accepts the lookahead rune.

Does nothing if there is no lookahead rune.

func (*Stream) Next

func (s *Stream) Next() (rune, error)

Next returns the next rune and consumes it.

Returns:

  • rune: The next rune.
  • error: The error if any.

func (*Stream) Peek

func (s *Stream) Peek() (rune, error)

Peek peeks the next rune without consuming it.

Returns:

  • rune: The next rune.
  • error: The error if any.

func (*Stream) Pos

func (s *Stream) Pos() int

Pos returns the current position of the stream.

Returns:

  • int: The current position.

Jump to

Keyboard shortcuts

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