[−][src]Crate toio
toio driver in Rust.
Supports all the messages defined in the technical specification. Provides async/await API. Provides the similar API as JavaScript version. Also provides the low-level API, which allows fine-grained control and configuration.
Plans to be cross-platform. The targets are:
- macOS
- Windows 10 (TODO)
- Linux (TODO)
use std::time::Duration; use toio::Cube; use tokio::time::delay_for; #[tokio::main] async fn main() { // Search for the nearest cube. let mut cube = Cube::search().nearest().await.unwrap(); // Connect. cube.connect().await.unwrap(); // Print status. println!("version : {}", cube.version().await.unwrap()); println!("battery : {}%", cube.battery().await.unwrap()); println!("button : {}", cube.button().await.unwrap()); // Move forward. cube.go(10, 10, None).await.unwrap(); delay_for(Duration::from_secs(3)).await; // Spin for 2 seconds. cube.go(100, 5, Some(Duration::from_secs(2))).await.unwrap(); delay_for(Duration::from_secs(3)).await; }
Re-exports
pub use proto::IdPos; |
pub use proto::IdStd; |
pub use proto::Posture; |
pub use proto::SoundPresetId; |
Modules
ble | Abstracts BLE. |
proto | Protocol data structures. |
Macros
uuid | Helper to construct |
Structs
Cube | The cube. |
LightOp | A light operation. |
Position | The cube position information. |
Searcher | Searcher to search cubes. |
SoundOp | A sound operation. |
StdId | The standard id information. |
Enums
Event | The event sent when the status is updated. |
Note | Sound note. |
Type Definitions
EventStream | The stream of events. |