clawtext

package
v0.0.0-...-599cc13 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: MIT Imports: 18 Imported by: 0

README

This directory is considered experimental. Anything here can change.

Documentation

Overview

Package clawtext provides functionality to marshal Claw structures to a human-readable text format and unmarshal text back into Claw structures.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalWriter

func MarshalWriter(ctx context.Context, v Walkable, w io.Writer, options ...MarshalOption) error

MarshalWriter marshals the Walkable to clawtext, writing to the provided io.Writer.

func Unmarshal

func Unmarshal(ctx context.Context, data []byte, v Ingester, options ...UnmarshalOption) error

Unmarshal parses clawtext data and populates the Ingester.

func UnmarshalReader

func UnmarshalReader(ctx context.Context, r io.Reader, v Ingester, options ...UnmarshalOption) error

UnmarshalReader parses clawtext from a reader and populates the Ingester.

Types

type Buffer

type Buffer struct {
	*bytes.Buffer
}

Buffer is a bytes.Buffer with a Release method to return it to the pool.

func Marshal

func Marshal(ctx context.Context, v Walkable, options ...MarshalOption) (Buffer, error)

Marshal marshals the Walkable to clawtext format.

func (Buffer) Release

func (b Buffer) Release(ctx context.Context)

Release returns the Buffer to the pool. Only use this once you are done with it.

type Ingester

type Ingester interface {
	Ingest(context.Context, clawiter.Walker, ...clawiter.IngestOption) error
}

Ingester is an interface for ingesting Claw tokens into a struct.

type MarshalOption

type MarshalOption func(marshalOptions) (marshalOptions, error)

MarshalOption provides options for marshaling Claw to clawtext.

func WithIndent

func WithIndent(indent string) MarshalOption

WithIndent configures the indentation string (default is 4 spaces).

func WithUseEnumNumbers

func WithUseEnumNumbers(use bool) MarshalOption

WithUseEnumNumbers configures whether enum values are emitted as numbers or strings.

func WithUseHexBytes

func WithUseHexBytes(use bool) MarshalOption

WithUseHexBytes configures whether byte arrays are emitted as hex instead of base64.

type UnmarshalOption

type UnmarshalOption func(unmarshalOptions) (unmarshalOptions, error)

UnmarshalOption provides options for unmarshaling clawtext to Claw.

func WithIgnoreUnknownFields

func WithIgnoreUnknownFields(ignore bool) UnmarshalOption

WithIgnoreUnknownFields configures whether unknown fields should be ignored.

type Walkable

type Walkable interface {
	Walk(ctx context.Context, yield clawiter.YieldToken, opts ...clawiter.WalkOption)
}

Walkable is an interface for types that can walk over Claw tokens.

Jump to

Keyboard shortcuts

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