yera.runtime.blocks.struct

Stream a struct schema followed by incremental JSON content.

Entering a StructStream emits the selected Yera struct's JSON Schema before any token chunks. Later chunks carry partial serialized content under the same block identity so renderers can show structured generation before the complete value is available.

Symbols

class StructStream — Stream a generated struct schema followed by its JSON tokens.

StructStream

Inherits: _StreamHandle

Stream a generated struct schema followed by its JSON tokens.

Methods

__init__ — Initialize a struct stream.
__enter__ — Open the stream and emit its struct schema.
__exit__ — Close the struct stream.
emit_schema — Emit a schema chunk for a struct type.
append — Append a JSON token chunk.

StructStream.__init__

__init__(
    block_id: str,
)

Initialize a struct stream.

Parameters

block_id
type: str

Identity shared by all emitted chunks.

cls
type: type[Struct]

Struct type whose schema begins the stream.

StructStream.__enter__

__enter__()

Open the stream and emit its struct schema.

Returns

This active struct stream.

StructStream.__exit__

__exit__(
    exc_type: type[BaseException],
    exc_value: BaseException | None,
    traceback: TracebackType,
)

Close the struct stream.

Parameters

exc_type
type: type[BaseException]

Type of exception leaving the context, if any.

exc_value
type: BaseException | None

Exception leaving the context, if any.

traceback
type: TracebackType

Traceback associated with the exception, if any.

Returns

False so exceptions propagate from the managed block.

StructStream.emit_schema

emit_schema() → None

Emit a schema chunk for a struct type.

Parameters

cls
type: type[Struct]

Struct type to describe.

StructStream.append

append(
    content: str,
) → None

Append a JSON token chunk.

Parameters

content
type: str

Partial serialized struct content.