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(data: PackedByteArray, offset: int = 0, count: int = -1) -> int, Errwrite_async(data: PackedByteArray, offset: int = 0, count: int = -1) -> await int, Errwrite_text(text: String, offset: int = 0, count: int = -1) -> int, Errwrite_text_async(text: String, offset: int = 0, count: int = -1) -> await int, Errflush() -> int, Errflush_async() -> await int, Err
write
write(data: PackedByteArray, offset: int = 0, count: int = -1) -> int, ErrWait behind preceding writes without ending the response.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
data | PackedByteArray | Required | Input data in the representation shown by the parameter type. |
offset | int | 0 | Zero-based starting position, in bytes unless the method explicitly operates on text characters. |
count | int | -1 | Number 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, ErrExpose an explicit asynchronous flush completion.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
data | PackedByteArray | Required | Input data in the representation shown by the parameter type. |
offset | int | 0 | Zero-based starting position, in bytes unless the method explicitly operates on text characters. |
count | int | -1 | Number 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, ErrEncode a character range and return accepted UTF-8 bytes with normal write backpressure.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
text | String | Required | Text to inspect, decode or transform; the input is not modified in place. |
offset | int | 0 | Zero-based character offset, before UTF-8 encoding. |
count | int | -1 | Number 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, ErrExpose text write completion as a signal.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
text | String | Required | Text to inspect, decode or transform; the input is not modified in place. |
offset | int | 0 | Zero-based character offset, before UTF-8 encoding. |
count | int | -1 | Number 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, ErrWait 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, ErrExpose 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.