tentacli/
lib.rs

1//! TentaCLI is embeddable, extendable console client for WoW 3.3.5a server.
2//!
3//! You can use it directly by compiling with cargo build,
4//! or you can incorporate it as a library in your own application.
5//! Also you can implement own feature set and pass it to the `run()` method.
6//! See `Feature` trait and `RunOptions`.
7//!
8//! What this client can do:
9//! - it can parse basic packet set, such as SMSG_MESSAGECHAT or SMSG_UPDATE_OBJECT
10//! - it allows you to login on any server, but you can enter the world only on servers without Warden anti-cheat
11//! - you can use `autoselect` options in config file to set default Realm/Character and avoid the step of selecting this data manually
12//! - if installed with `ui` feature (installed by default), it allows scrolling the packets history using keyboard and seeing the details for each packet
13//! - if installed with `console` feature, it will display only minimal output
14//! - if installed without any feature, client will output nothing (but you still can provide own output feature)
15//! - you can implement own packet processors and send them using custom features
16//! - you can pass external data storage to the tentacli using **CreateOptions**
17//!
18//! ## Examples
19//!
20//! ```rust
21//! use std::collections::BTreeMap;
22//! use anyhow::{Result as AnyResult};
23//! use tokio::task::JoinHandle;
24//!
25//! use tentacli::async_broadcast::{BroadcastSender, BroadcastReceiver};
26//! use tentacli::{Client, CreateOptions, RunOptions};
27//! use tentacli_traits::{Feature, FeatureError};
28//! use tentacli_traits::types::{HandlerOutput, ProcessorFunction, ProcessorResult};
29//!
30//! #[tokio::main]
31//! async fn main() {
32//!     #[derive(Default)]
33//!     pub struct MyFeature {
34//!         _receiver: Option<BroadcastReceiver<HandlerOutput>>,
35//!         _sender: Option<BroadcastSender<HandlerOutput>>,
36//!     }
37//!
38//!     impl Feature for MyFeature {
39//!         fn set_broadcast_channel(
40//!             &mut self,
41//!             sender: BroadcastSender<HandlerOutput>,
42//!             receiver: BroadcastReceiver<HandlerOutput>
43//!         ) {
44//!             self._sender = Some(sender);
45//!             self._receiver = Some(receiver);
46//!         }
47//!
48//!         fn get_tasks(&mut self) -> AnyResult<Vec<JoinHandle<()>>> {
49//!             let mut receiver = self._receiver.as_mut().ok_or(FeatureError::ReceiverNotFound)?.clone();
50//!
51//!             let handle_smth = || {
52//!                 tokio::spawn(async move {
53//!                     loop {
54//!                         if let Ok(output) = receiver.recv().await {
55//!                             match output {
56//!                                 HandlerOutput::SuccessMessage(message, _) => {
57//!                                     println!("{}", message);
58//!                                 }
59//!                                 _ => {}
60//!                             }
61//!                         }
62//!                     }
63//!                 })
64//!             };
65//!
66//!             Ok(vec![handle_smth()])
67//!         }
68//!
69//!         fn get_login_processors(&self) -> Vec<ProcessorFunction> {
70//!             vec![]
71//!         }
72//!
73//!         fn get_realm_processors(&self) -> Vec<ProcessorFunction> {
74//!             vec![]
75//!         }
76//!
77//!         fn get_one_time_handler_maps(&self) -> Vec<BTreeMap<u16, ProcessorResult>> {
78//!             vec![]
79//!         }
80//!
81//!         fn get_initial_processors(&self) -> Vec<ProcessorFunction> {
82//!             vec![]
83//!         }
84//!     }
85//!
86//!     let options = RunOptions {
87//!         external_features: vec![Box::new(MyFeature::default())],
88//!         account: "account_name",
89//!         config_path: "./dir/another_dir/ConfigFileName.yml",
90//!         dotenv_path: "./path/to/.env"
91//!     };
92//!
93//!     // ... pass options to the client
94//!     // Client::new(CreateOptions::default()).run(options).await.unwrap();
95//! }
96//! ```
97
98#[cfg(feature = "ui")]
99extern crate chrono;
100#[macro_use]
101extern crate tentacli_packet;
102#[macro_use]
103extern crate serde;
104#[macro_use]
105extern crate cfg_if;
106
107mod features;
108mod primary;
109
110pub use primary::client::{Client, CreateOptions, RunOptions};
111
112pub mod async_broadcast {
113    pub use async_broadcast::{broadcast, Sender as BroadcastSender, Receiver as BroadcastReceiver};
114}
115
116pub mod serializers {
117    pub use crate::primary::serializers::{serialize_array};
118}