44 lines
1.4 KiB
Rust
44 lines
1.4 KiB
Rust
//! Minimal OC2R HLAPI client for Rust.
|
|
//!
|
|
//! This crate mirrors the behaviour of the bundled Lua `devices.lua`
|
|
//! helper. It communicates with the OC2R RPC controller over the first
|
|
//! VirtIO console device (`/dev/hvc0`) and exposes helpers for listing
|
|
//! devices, inspecting available methods and invoking them.
|
|
//!
|
|
//! # Quick start
|
|
//! ```no_run
|
|
//! use oc2r_rust::{DeviceBus, Result, DEFAULT_DEVICE_PATH};
|
|
//!
|
|
//! fn main() -> Result<()> {
|
|
//! let mut bus = DeviceBus::connect(DEFAULT_DEVICE_PATH)?;
|
|
//! let devices = bus.list()?;
|
|
//! println!("Found {} device(s)", devices.len());
|
|
//!
|
|
//! if let Some(entry) = devices.first() {
|
|
//! if let Some(mut device) = bus.device(&entry.device_id)? {
|
|
//! let response = device.call("help", ())?;
|
|
//! println!("help(): {response:?}");
|
|
//! }
|
|
//! }
|
|
//! Ok(())
|
|
//! }
|
|
//! ```
|
|
|
|
pub mod bus;
|
|
pub mod devices;
|
|
pub mod error;
|
|
pub mod rpc;
|
|
mod transport;
|
|
mod value;
|
|
|
|
pub use bus::{Device, DeviceBus};
|
|
pub use devices::{
|
|
BlockOperations, Cpu, EnergyStorage, FileImportExport, FluidHandler, ImportedFileInfo,
|
|
InventoryOperations, ItemHandler, ParseSideError, Redstone, RobotSide, Side, SoundCard,
|
|
};
|
|
pub use error::{Error, Result};
|
|
pub use rpc::{DeviceEntry, JsonValue, MethodEntry, MethodParameter};
|
|
pub use value::{IntoJsonArgs, IntoJsonValue};
|
|
|
|
pub const DEFAULT_DEVICE_PATH: &str = "/dev/hvc0";
|