Skip to content

feat(xml): implement async parsing #49

@lowlighter

Description

@lowlighter

Currently we support ReaderSync but it's be nice to be able to pass a async Reader

/** Asynchronous reader. */
type Reader = { read(buffer: Uint8Array): Promise<Nullable<number>> }

/** Mocked reader */
class MockReader implements Reader {
  constructor(string: string) {
    this.#data = new TextEncoder().encode(string)
  }
  readonly #data
  #cursor = 0
  async read(buffer: Uint8Array) {
    const bytes = this.#data.slice(this.#cursor, this.#cursor + buffer.length)
    buffer.set(bytes)
    this.#cursor = Math.min(this.#cursor + bytes.length, this.#data.length)
    return bytes.length || null
  }
}

This however may require a bit of work since we need to patch xml/wasm_xml_parser/src/lib.rs to support asynchronous reading, possibly using tokio ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions