asterisk_ari/lib.rs
1//! Asterisk ARI Client
2//!
3//! This crate provides a simple yet powerful Rust library for managing the
4//! [Asterisk](https://www.asterisk.org/) ARI (Asterisk REST Interface). It offers
5//! full implementation of Asterisk's REST APIs and WebSocket event handling,
6//! enabling developers to build custom telephony applications with ease.
7//!
8//! ## Features
9//!
10//! - Comprehensive coverage of Asterisk REST APIs.
11//! - WebSocket support for real-time ARI event streaming.
12//! - Designed for simplicity and ease of use.
13//! - Ideal for telephony application development and integration.
14//!
15//! ## Quick Start
16//!
17//! To use this crate, add it to your `Cargo.toml`:
18//!
19//! ```toml
20//! [dependencies]
21//! asterisk-ari-rs = "x.y.z" // Replace with the latest version
22//! ```
23//!
24//! ### Example
25//!
26//! ```no_run
27//! use asterisk_ari::apis::channels;
28//! use asterisk_ari::AriClient;
29//! use asterisk_ari::Config;
30//! use asterisk_ari::Result;
31//!
32//! #[tokio::main]
33//! async fn main() -> Result<()> {
34//!
35//! let config = Config::new("http://localhost:8088", "asterisk", "asterisk");
36//!
37//! let mut client = AriClient::with_config(config);
38//!
39//! client.on_stasis_start(|client, event| async move {
40//! println!("Handling StasisStart event: {:?}", event);
41//!
42//! client
43//! .channels()
44//! .answer(&event.data.channel.id)
45//! .await
46//! .unwrap();
47//!
48//! client
49//! .channels()
50//! .play(channels::params::PlayRequest::new(
51//! &event.data.channel.id,
52//! "sound:tt-monkeys",
53//! ))
54//! .await
55//! .unwrap();
56//! });
57//!
58//! println!("Applications: {:?}", client.applications().list().await?);
59//! println!("Ping: {:?}", client.asterisk().ping().await?);
60//! println!("Info: {:?}", client.asterisk().info().await?);
61//!
62//! let _client = client.clone();
63//! tokio::spawn(async move {
64//! _client.start("my-application".to_string()).await.unwrap();
65//! });
66//!
67//! tokio::time::sleep(std::time::Duration::from_secs(30)).await;
68//!
69//! println!("Stopping client");
70//! client.stop();
71//!
72//! println!("Await client to stop");
73//! tokio::time::sleep(std::time::Duration::from_secs(4)).await;
74//!
75//! Ok(())
76//! }
77//! ```
78//!
79//!
80//! ## License
81//!
82//! This crate is dual-licensed under the [Apache License 2.0](LICENSE-APACHE) or
83//! [MIT License](LICENSE-MIT). Choose the license that suits your project.
84
85/// Apis implementation
86pub mod apis;
87mod config;
88pub use config::*;
89mod errors;
90pub use errors::*;
91mod client;
92pub use client::*;
93/// WebSocket implementation
94pub mod ws;