Expand description
Typed Rust bindings to OpenComputers, for programs running on the WebAssembly (wackasm) architecture.
Build an ordinary WASI program (--target wasm32-wasip1) and use
components directly:
use wackasm_opencomputers::prelude::*;
let gpu = Gpu::first().expect("no GPU");
let (w, h) = gpu.get_resolution()?;
gpu.fill(1, 1, w, h, " ")?;
gpu.set(1, 1, "hello from Rust", None)?;
// Wait for a key.
let key = signal::pull_filtered(None, |s| matches!(s, Signal::KeyDown { .. }));components: a generated struct per component type (Gpu,Filesystem,Robot,Modem,Redstone, …), with a method for every callback and OpenComputers’ own docs.component: finding components, and untyped calls (Proxy).signal: typed events.computer: this computer’s address, uptime, memory and power.process: running other programs, likestd::process.draw: a framebuffer with text, half-block pixels, braille and shapes, sent to the GPU with as few calls as possible.internet: HTTP requests and TCP connections through an internet card.pattern_provider: autocrafting patterns for Applied Energistics 2 that the program fulfils (with AE2 installed).task(with theasyncfeature): an async executor, so programs can wait on several component calls, timers and signals at once. Every component method then has an_asynctwin.Side,Color,keys: the numeric codes components use.
Files are simplest through std::fs, which the architecture maps onto a
disk. The Filesystem wrapper is there for other disks.
Numbers cross as Number: an integer or a float, as OpenComputers sent
it, so integers stay exact.
Re-exports§
pub use component::Address;pub use component::Component;pub use component::MethodInfo;pub use component::Proxy;pub use signal::Signal;
Modules§
- component
- Finding components and calling them.
- components
- Typed wrappers for every OpenComputers component.
- computer
- This computer: its address, uptime, memory, beeps, and power.
(The
computercomponent itself iscrate::components::Computer.) - draw
- Easy, efficient drawing: draw into a
Canvasin your program’s memory, thenCanvas::presentsends only what changed to the GPU, in as few calls as it can. - internet
- HTTP(S) requests and TCP connections through an internet card.
- keys
- Keyboard codes (
Signal::KeyDown::code), for keys without a character. - pattern_
provider - The Computer Pattern Provider: autocrafting patterns for Applied Energistics 2 that a program fulfils.
- prelude
- Everything a typical program needs:
use wackasm_opencomputers::prelude::*; - process
- Running other programs, in the style of
std::process. - signal
- Events: key presses, screen touches, network messages, components appearing, and so on. OpenComputers queues them per computer.
- task
- A small single-threaded async executor driven by OpenComputers: tasks
wait on component calls, signals and timers, and the computer sleeps until
one of them is ready. Enable the crate’s
asyncfeature to use it.
Structs§
- Handle
- A host object the guest holds by reference, such as an open file handle
from
filesystem.open. Pass it back to the component that made it. - OcString
- A Lua string: bytes that are usually, but not always, UTF-8 (file contents, hashes and EEPROM code come back as binary).
Enums§
- Color
- A bundled-redstone / dye colour index.
- Error
- Why a component call failed.
- Number
- A Lua number: an integer, or a float when OpenComputers sends one.
- Side
- A side, as robots, drones, redstone and transposers number them. Relative names apply to robots and drones; absolute ones to blocks.
- Value
- Any value a component takes or returns.