Skip to content

The Python, Node.js and Rust clients: how to install them, how their names map to each other, and how a call returns.

VirtX has one client in three languages: virtx for Python, @brekkylab/virtx for Node.js and the virtx crate for Rust. All three make their requests through the same library, libvirtx_core, so they send the same requests and return the same values. Installation covers what each needs.

pip install virtx

Names

Python’s names are the reference’s own. Node.js uses the same names in camelCase, such as createSandbox for create_sandbox, and fields in camelCase, such as memoryMib. Rust uses the same names as Python, and passes a call’s options in one struct, such as SandboxCreateArgs. Each entry in this reference shows all three.

How a call returns

A call is a coroutine: await it for its value. A call that starts a job returns a StartedJob: awaited, it is the job; iterated with async for, it yields the job’s log, a LogEntry at a time; complete() follows it to its end. download_image and upload_image are async iterators of Progress events, then one Output.

When a request is sent differs by language, and in each it is sent once, however its value is used:

  • Python: the calls are async def, so nothing is sent until the value is awaited, or, for a StartedJob, first awaited or iterated.
  • Node.js and Rust: the request is sent when the method is called.

Calls that fail raise, throw or return the same error in each language: see Errors.

The reference