Browse Source

Run in async mode by default.

wip
Titouan Rigoudy 4 years ago
parent
commit
5d86a29e96
2 changed files with 11 additions and 11 deletions
  1. +4
    -4
      client/src/config.rs
  2. +7
    -7
      client/src/main.rs

+ 4
- 4
client/src/config.rs View File

@ -33,11 +33,11 @@ pub struct TomlConfig {
}
impl TomlConfig {
fn from_str(s: &str) -> Result<Self, toml::de::Error> {
pub fn from_str(s: &str) -> Result<Self, toml::de::Error> {
toml::from_str(s)
}
async fn from_file_path(path: &Path) -> anyhow::Result<Self> {
pub async fn from_file_path(path: &Path) -> anyhow::Result<Self> {
let mut file =
File::open(path).await.context("opening toml config file")?;
@ -88,7 +88,7 @@ impl Default for Config {
impl Config {
/// Builds a new config with the given `credentials` and default values.
fn new(credentials: Credentials) -> Self {
pub fn new(credentials: Credentials) -> Self {
Self {
credentials,
server_address: "server.slsknet.org:2242".to_string(),
@ -100,7 +100,7 @@ impl Config {
}
/// Attempts to build a `Config` from the given `TomlConfig`.
fn from_toml(toml: TomlConfig) -> anyhow::Result<Self> {
pub fn from_toml(toml: TomlConfig) -> anyhow::Result<Self> {
let credentials = Credentials::new(toml.user_name, toml.password)
.context("validating credentials")?;


+ 7
- 7
client/src/main.rs View File

@ -138,19 +138,19 @@ async fn main() -> anyhow::Result<()> {
.version("0.1")
.author("letitz")
.arg(
Arg::with_name("async")
.long("async")
.help("Use the new async engine."),
Arg::with_name("sync")
.long("sync")
.help("Use the old synchronous engine."),
)
.get_matches();
if matches.is_present("async") {
info!("Running in asynchronous mode.");
async_main().await.context("running asynchronous main")
} else {
if matches.is_present("sync") {
info!("Running in synchronous mode.");
tokio::task::spawn_blocking(old_main)
.await
.context("running synchronous main")
} else {
info!("Running in asynchronous mode.");
async_main().await.context("running asynchronous main")
}
}

Loading…
Cancel
Save