Create euphoxide-client crate
This commit is contained in:
parent
5dff3afd8c
commit
0dc0123083
8 changed files with 780 additions and 2 deletions
71
euphoxide-client/src/config.rs
Normal file
71
euphoxide-client/src/config.rs
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
use std::{
|
||||
sync::{Arc, Mutex},
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use cookie::CookieJar;
|
||||
use euphoxide::client::conn::ClientConnConfig;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[non_exhaustive]
|
||||
pub struct ServerConfig {
|
||||
pub client: ClientConnConfig,
|
||||
pub cookies: Arc<Mutex<CookieJar>>,
|
||||
pub join_attempts: usize,
|
||||
pub reconnect_delay: Duration,
|
||||
pub cmd_channel_bufsize: usize,
|
||||
}
|
||||
|
||||
impl Default for ServerConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
client: ClientConnConfig::default(),
|
||||
cookies: Arc::new(Mutex::new(CookieJar::new())),
|
||||
join_attempts: 5,
|
||||
reconnect_delay: Duration::from_secs(30),
|
||||
cmd_channel_bufsize: 1,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[non_exhaustive]
|
||||
pub struct ClientConfig {
|
||||
pub server: ServerConfig,
|
||||
pub room: String,
|
||||
pub human: bool,
|
||||
pub username: Option<String>,
|
||||
pub force_username: bool,
|
||||
pub password: Option<String>,
|
||||
}
|
||||
|
||||
impl ClientConfig {
|
||||
pub fn new(server: ServerConfig, room: String) -> Self {
|
||||
Self {
|
||||
server,
|
||||
room,
|
||||
human: false,
|
||||
username: None,
|
||||
force_username: false,
|
||||
password: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[non_exhaustive]
|
||||
pub struct MultiClientConfig {
|
||||
pub server: ServerConfig,
|
||||
pub cmd_channel_bufsize: usize,
|
||||
pub event_channel_bufsize: usize,
|
||||
}
|
||||
|
||||
impl Default for MultiClientConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
server: ServerConfig::default(),
|
||||
cmd_channel_bufsize: 1,
|
||||
event_channel_bufsize: 10,
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue