Documentation
¶
Overview ¶
Package clawtext provides functionality to marshal Claw structures to a human-readable text format and unmarshal text back into Claw structures.
Index ¶
- func MarshalWriter(ctx context.Context, v Walkable, w io.Writer, options ...MarshalOption) error
- func Unmarshal(ctx context.Context, data []byte, v Ingester, options ...UnmarshalOption) error
- func UnmarshalReader(ctx context.Context, r io.Reader, v Ingester, options ...UnmarshalOption) error
- type Buffer
- type Ingester
- type MarshalOption
- type UnmarshalOption
- type Walkable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalWriter ¶
MarshalWriter marshals the Walkable to clawtext, writing to the provided io.Writer.
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 ¶
Buffer is a bytes.Buffer with a Release method to return it to the pool.
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.