API reference
Preparing search index…

StreamCallbacks

Synchronous implementations of Rml::Stream virtual methods.

Methods are captured once. Read and peek receive owned scratch arrays; writes receive snapshots. Return exact counts or booleans, never Promises. Native API reentry is rejected. Callback cycles remain visible to the GC.

interface StreamCallbacks {
    peek?: (output: Uint8Array, count: number) => number;
    popBack?: (length: number) => number;
    popFront?: (length: number) => number;
    pushBack?: (input: Uint8Array, count: number) => number;
    pushFront?: (input: Uint8Array, count: number) => number;
    close(): void;
    isEOS(): boolean;
    isReadReady(): boolean;
    isWriteReady(): boolean;
    length(): number;
    read(output: Uint8Array, count: number): number;
    seek(offset: number, origin: SeekOrigin): boolean;
    tell(): number;
    truncate(length: number): number;
    write(input: Uint8Array, count: number): number;
}
Source & inheritance
Member directory15

Properties

Methods

Properties

peek?: (output: Uint8Array, count: number) => number

Optional read without advancing; defaults to read followed by seek.

Type declaration

    • (output: Uint8Array, count: number): number
    • Read into owned scratch storage and advance the cursor.

      Parameters

      output
      Uint8Array

      Scratch bytes; never detach or resize its buffer.

      count
      number

      Maximum number of bytes to read.

      Returns

      number

      Integer in [0, count].

Source & inheritance
popBack?: (length: number) => number

Optional tail removal; defaults to truncate().

Type declaration

    • (length: number): number
    • Reduce the length and return the number of removed bytes.

      Parameters

      length
      number

      Requested byte length.

      Returns

      number

      Nonnegative safe integer count of removed bytes.

Source & inheritance
popFront?: (length: number) => number

Optional front removal; absence throws.

Type declaration

    • (length: number): number
    • Reduce the length and return the number of removed bytes.

      Parameters

      length
      number

      Requested byte length.

      Returns

      number

      Nonnegative safe integer count of removed bytes.

Source & inheritance
pushBack?: (input: Uint8Array, count: number) => number

Optional append; defaults to seek, write and cursor restoration.

Type declaration

    • (input: Uint8Array, count: number): number
    • Write the supplied independent byte snapshot.

      Parameters

      input
      Uint8Array

      Owned snapshot; changes cannot affect the caller.

      count
      number

      Maximum number of bytes to write.

      Returns

      number

      Integer in [0, count].

Source & inheritance
pushFront?: (input: Uint8Array, count: number) => number

Optional prepend operation; absence throws.

Type declaration

    • (input: Uint8Array, count: number): number
    • Write the supplied independent byte snapshot.

      Parameters

      input
      Uint8Array

      Owned snapshot; changes cannot affect the caller.

      count
      number

      Maximum number of bytes to write.

      Returns

      number

      Integer in [0, count].

Source & inheritance

Methods

  • Optional explicit close callback; never invoked by GC or shutdown.

    Returns

    void
    Source & inheritance
  • Optional EOF test; defaults to tell() greater than or equal to length().

    Returns

    boolean

    End-of-stream state.

    Source & inheritance
  • Return whether bytes are ready for reading.

    Returns

    boolean

    Reading readiness.

    Source & inheritance
  • Return whether bytes can be written now.

    Returns

    boolean

    Writing readiness.

    Source & inheritance
  • Return the total byte length as a nonnegative safe integer.

    Returns

    number

    Total byte length.

    Source & inheritance
  • Read into owned scratch storage and advance the cursor.

    Parameters

    output
    Uint8Array

    Scratch bytes; never detach or resize its buffer.

    count
    number

    Maximum number of bytes to read.

    Returns

    number

    Integer in [0, count].

    Source & inheritance
  • Implement native seek; choose the callback's end-offset convention.

    Parameters

    offset
    number

    Signed byte offset.

    origin

    Native seek origin.

    Returns

    boolean

    Whether the cursor moved successfully.

    Source & inheritance
  • Return the current byte position as a nonnegative safe integer.

    Returns

    number

    Current byte position.

    Source & inheritance
  • Reduce the length and return the number of removed bytes.

    Parameters

    length
    number

    Requested byte length.

    Returns

    number

    Nonnegative safe integer count of removed bytes.

    Source & inheritance
  • Write the supplied independent byte snapshot.

    Parameters

    input
    Uint8Array

    Owned snapshot; changes cannot affect the caller.

    count
    number

    Maximum number of bytes to write.

    Returns

    number

    Integer in [0, count].

    Source & inheritance

Icons made by Lorc, Delapouite & Skoll · game-icons.net · CC BY 3.0