gdDocumentation0.8.0

API reference

GDWebWriter

The byte destination passed to a GD.web.stream producer. write(data, offset=0, count=-1) sends a range and returns accepted bytes, waiting while the connection is backed up. write_text(text, offset=0, count=-1) sends a character range as UTF-8. count=-1 selects the remainder. flush waits until preceding writes are sent. Detect disconnects through flush errors and request-context cancellation.

Methods

write

write(data: PackedByteArray, offset: int = 0, count: int = -1) -> int, Err

Wait behind preceding writes without ending the response.

Parameters

NameTypeDefaultDescription
dataPackedByteArrayRequiredInput data in the representation shown by the parameter type.
offsetint0Zero-based starting position, in bytes unless the method explicitly operates on text characters.
countint-1Number of elements to consume from the starting position; -1 selects the remainder where supported.

Return value

int, Err

Suspends only the calling routine until the operation completes. No explicit await is needed.

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

write_async

write_async(data: PackedByteArray, offset: int = 0, count: int = -1) -> await int, Err

Expose an explicit asynchronous flush completion.

Parameters

NameTypeDefaultDescription
dataPackedByteArrayRequiredInput data in the representation shown by the parameter type.
offsetint0Zero-based starting position, in bytes unless the method explicitly operates on text characters.
countint-1Number of elements to consume from the starting position; -1 selects the remainder where supported.

Return value

await int, Err

Returns a Signal. Use await to receive the completion value shown in the signature.

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

write_text

write_text(text: String, offset: int = 0, count: int = -1) -> int, Err

Encode a character range and return accepted UTF-8 bytes with normal write backpressure.

Parameters

NameTypeDefaultDescription
textStringRequiredText to inspect, decode or transform; the input is not modified in place.
offsetint0Zero-based character offset, before UTF-8 encoding.
countint-1Number of characters to encode; -1 selects the remainder.

Return value

int, Err

Suspends only the calling routine until the operation completes. No explicit await is needed.

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

write_text_async

write_text_async(text: String, offset: int = 0, count: int = -1) -> await int, Err

Expose text write completion as a signal.

Parameters

NameTypeDefaultDescription
textStringRequiredText to inspect, decode or transform; the input is not modified in place.
offsetint0Zero-based character offset, before UTF-8 encoding.
countint-1Number of characters to encode; -1 selects the remainder.

Return value

await int, Err

Returns a Signal. Use await to receive the completion value shown in the signature.

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

flush

flush() -> int, Err

Wait behind preceding writes without ending the response.

Parameters

No parameters.

Return value

int, Err

Suspends only the calling routine until the operation completes. No explicit await is needed.

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

flush_async

flush_async() -> await int, Err

Expose an explicit asynchronous flush completion.

Parameters

No parameters.

Return value

await int, Err

Returns a Signal. Use await to receive the completion value shown in the signature.

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.