Compare commits

..

5 Commits

Author SHA1 Message Date
Gwen Lg
1b31a5d060 fix lint clippy::needless_question_mark
for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_question_mark
2024-06-13 23:20:19 +02:00
Gwen Lg
738ece6f92 wip: improve error management with thiserror 2024-06-13 23:19:11 +02:00
Gwen Lg
c7b111a53e add thiserror dependency 2024-06-13 23:19:10 +02:00
Gwen Lg
9a84a9b749 update dependencies in Cargo.toml
update: zip, reqwest and env_logger
2024-06-13 23:17:37 +02:00
Gwen Lg
c0854cfb69 fix fmt in Cargo.toml 2024-06-13 23:17:35 +02:00
3 changed files with 964 additions and 502 deletions

1453
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -14,18 +14,18 @@ categories = ["text-processing"]
[dependencies] [dependencies]
serde_json = "1.0.96" serde_json = "1.0.96"
reqwest = { version = "0.11.18", features = ["json"] } reqwest = { version = "0.12.4", features = ["json"] }
serde = { version = "1.0.163", features = ["derive"] } serde = { version = "1.0.163", features = ["derive"] }
log = "0.4.17" log = "0.4.17"
zip = { version = "0.6.3", optional = true } zip = { version = "2.1.3", optional = true }
mktemp = { version = "0.5.0", optional = true } mktemp = { version = "0.5.0", optional = true }
rand = { version = "0.8.5", optional = true } rand = { version = "0.8.5", optional = true }
port_scanner = {version = "0.1.5", optional = true} port_scanner = { version = "0.1.5", optional = true }
thiserror = "1.0.61" thiserror = "1.0.61"
[features] [features]
embedded-server = ["zip", "mktemp", "rand", "port_scanner"] embedded-server = ["zip", "mktemp", "rand", "port_scanner"]
[dev-dependencies] [dev-dependencies]
env_logger = "0.10.0" env_logger = "0.11.3"
tokio = { version = "1.28.1", features = ["full"] } tokio = { version = "1.28.1", features = ["full"] }

View File

@ -305,6 +305,7 @@ pub struct SuggestResult {
#[derive(Debug, Error)] #[derive(Debug, Error)]
pub enum Error { pub enum Error {
#[cfg(feature = "embedded-server")]
#[error("Grammalecte-server failed to start")] #[error("Grammalecte-server failed to start")]
ServerStartFailed(#[from] server::Error), ServerStartFailed(#[from] server::Error),
@ -410,7 +411,7 @@ impl GrammalecteClient {
let mut params = HashMap::new(); let mut params = HashMap::new();
params.insert("token", token); params.insert("token", token);
Ok(reqwest::Client::new() reqwest::Client::new()
.post(&url) .post(&url)
.form(&params) .form(&params)
.send() .send()
@ -418,7 +419,7 @@ impl GrammalecteClient {
.map_err(Error::RequestSendSuggest)? .map_err(Error::RequestSendSuggest)?
.json() .json()
.await .await
.map_err(Error::SuggestDeserialize)?) .map_err(Error::SuggestDeserialize)
} }
} }