arduino_cli_client/lib.rs
1//! # Example
2//!
3//! Make sure to run the following before:
4//! ```text
5//! arduino-cli daemon
6//! ```
7//!
8//! ## Code
9//!
10//! ```rust
11//! use arduino_cli_client::commands::arduino_core_client::ArduinoCoreClient;
12//! use arduino_cli_client::commands::{BoardListReq, InitReq};
13//!
14//! #[tokio::main]
15//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
16//! let mut client = ArduinoCoreClient::connect("http://localhost:50051").await?;
17//!
18//! // Start a new instance of the Arduino Core Service
19//! let mut init_stream = client
20//! .init(InitReq {
21//! library_manager_only: false,
22//! })
23//! .await?
24//! .into_inner();
25//!
26//! let resp_instance = init_stream.message().await?.expect("Failed to init");
27//!
28//! // List the boards currently connected to the computer.
29//! let resp_boards = client
30//! .board_list(BoardListReq {
31//! instance: resp_instance.instance,
32//! })
33//! .await?
34//! .into_inner();
35//!
36//! print!("Boards: {:?}", resp_boards.ports);
37//!
38//! Ok(())
39//! }
40//! ```
41//!
42
43/// Main Arduino Platform service
44pub mod commands {
45 tonic::include_proto!("cc.arduino.cli.commands");
46}
47
48/// Service that abstract a debug Session usage
49pub mod debug {
50 tonic::include_proto!("cc.arduino.cli.debug");
51}
52
53/// Service that abstracts a Monitor usage
54pub mod monitor {
55 tonic::include_proto!("cc.arduino.cli.monitor");
56}
57
58/// The Settings service provides an interface to Arduino CLI's configuration options
59pub mod settings {
60 tonic::include_proto!("cc.arduino.cli.settings");
61}
62
63pub use crate::commands::arduino_core_client::ArduinoCoreClient;
64pub use crate::debug::debug_client::DebugClient;
65pub use crate::monitor::monitor_client::MonitorClient;
66pub use crate::settings::settings_client::SettingsClient;