Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(xml): implement async parsing #49

Open
lowlighter opened this issue May 31, 2024 · 0 comments
Open

feat(xml): implement async parsing #49

lowlighter opened this issue May 31, 2024 · 0 comments

Comments

@lowlighter
Copy link
Owner

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 ?

lowlighter added a commit that referenced this issue May 31, 2024
@lishaduck lishaduck mentioned this issue Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant