gdDocumentation0.8.0

API reference

GDFileStream

Reader, Writer, and Closer for ordered incremental access to a regular file. Separate streams proceed concurrently.

Methods

read

read(max: int = 32768) -> PackedByteArray, Err

Read up to the requested bytes; an empty success result denotes EOF when the requested count is positive.

Parameters

NameTypeDefaultDescription
maxint32768Maximum bytes requested by one read.

Return value

PackedByteArray, 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.

read_async

read_async(max: int = 32768) -> await PackedByteArray, Err

Read up to the requested bytes; an empty success result denotes EOF when the requested count is positive.

Parameters

NameTypeDefaultDescription
maxint32768Maximum bytes requested by one read.

Return value

await PackedByteArray, 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

write(data: PackedByteArray) -> int, Err

Write all supplied bytes and return the written count.

Parameters

NameTypeDefaultDescription
dataPackedByteArrayRequiredInput data in the representation shown by the parameter type.

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) -> await int, Err

Write all supplied bytes and return the written count.

Parameters

NameTypeDefaultDescription
dataPackedByteArrayRequiredInput data in the representation shown by the parameter type.

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.

seek

seek(offset: int) -> Variant, Err

Move the next I/O position to a byte offset from the start.

Parameters

NameTypeDefaultDescription
offsetintRequiredZero-based starting position, in bytes unless the method explicitly operates on text characters.

Return value

Variant, 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.

seek_async

seek_async(offset: int) -> await Variant, Err

Move the next I/O position to a byte offset from the start.

Parameters

NameTypeDefaultDescription
offsetintRequiredZero-based starting position, in bytes unless the method explicitly operates on text characters.

Return value

await Variant, 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.

close

close() -> Variant, Err

Close the file after preceding operations.

Parameters

No parameters.

Return value

Variant, 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.

close_async

close_async() -> await Variant, Err

Close the file after preceding operations.

Parameters

No parameters.

Return value

await Variant, 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.

is_open

is_open() -> bool

Return whether the file has been opened and closing has not started.

Parameters

No parameters.

Return value

bool

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.