class documentation

A container for a value encoded in an underlying stream.

It is used to stream inputs and outputs in the various client and server APIs.

Example

# Creating a LazyValue from raw data
lazy_input = LazyValue(
    serializer=my_serializer,
    headers={"content-type": "application/json"},
    stream=async_data_stream
)

# Using LazyValue with Handler.start_operation
handler = nexusrpc.handler.Handler([my_service])
result = await handler.start_operation(ctx, lazy_input)

# Consuming a LazyValue directly
deserialized_data = await lazy_input.consume(as_type=MyInputType)
Method __init__ No summary
Async Method consume Consume the underlying reader stream, deserializing via the embedded serializer.
Instance Variable headers Undocumented
Instance Variable serializer Undocumented
Instance Variable stream Undocumented
def __init__(self, serializer: Serializer, headers: Mapping[str, str], stream: AsyncIterable[bytes] | None = None):
Parameters
serializer:SerializerThe serializer to use for consuming the value.
headers:Mapping[str, str]Headers that include information on how to process the stream's content. Headers constructed by the framework always have lower case keys. User provided keys are treated case-insensitively.
stream:AsyncIterable[bytes] | NoneAsyncIterable of bytes that contains request or response data. None means empty data.
async def consume(self, as_type: type[Any] | None = None) -> Any:

Consume the underlying reader stream, deserializing via the embedded serializer.

headers =

Undocumented

serializer =

Undocumented

stream =

Undocumented