byteview

package
v0.0.0-...-b13b7c6 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package byteview provides a mechanism to handle strings and []byte as immutable byte views.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UnsafeAs

func UnsafeAs[T string | []byte](v ByteView) T

UnsafeAs converts a ByteView to type T independently of what it was originally. This is only safe if the type is the same one used for From and either the result is not modified or the ByteView is no longer used.

Types

type Builder

type Builder[T string | []byte] struct {
	// contains filtered or unexported fields
}

func (*Builder[T]) Build

func (b *Builder[T]) Build() T

func (*Builder[T]) Grow

func (b *Builder[T]) Grow(n int)

func (*Builder[T]) Write

func (b *Builder[T]) Write(v []byte) (n int, err error)

func (*Builder[T]) WriteByteView

func (b *Builder[T]) WriteByteView(v ByteView) (n int, err error)

func (*Builder[T]) WriteString

func (b *Builder[T]) WriteString(v string) (n int, err error)

type ByteView

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

func From

func From[T string | []byte](in T) ByteView

func SplitLines

func SplitLines(v ByteView) (lines []ByteView, missingNewline int)

SplitLines splits the input on '\n' and returns the lines including the newline character and and either -1 if the last line ends in a newline character or len([]ByteView) if it's missing a newline character.

func (ByteView) Bytes

func (v ByteView) Bytes() iter.Seq[byte]

func (ByteView) Len

func (v ByteView) Len() int

Jump to

Keyboard shortcuts

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