Minor improvments

This commit is contained in:
Pierre HUBERT 2022-12-19 14:21:31 +01:00
parent 4ea83ee693
commit 17c1b69757
3 changed files with 6 additions and 5 deletions

2
Cargo.lock generated
View File

@ -349,7 +349,7 @@ dependencies = [
[[package]]
name = "grammalecte_client"
version = "0.1.0"
version = "0.1.1"
dependencies = [
"env_logger",
"log",

View File

@ -270,7 +270,7 @@ pub struct GrammarError {
#[serde(rename = "sType")]
pub rule_type: String,
#[serde(rename = "aColor")]
pub rule_underline_color: Vec<u8>,
pub rule_underline_color: Option<Vec<u8>>,
#[serde(rename = "sMessage")]
pub message: String,
#[serde(rename = "aSuggestions")]
@ -342,14 +342,14 @@ impl GrammalecteClient {
/// Run spell check on text
pub async fn spell_check(&self, text: &str) -> Result<CheckResult, Box<dyn Error>> {
self.spell_check_with_options(text, HashMap::new()).await
self.spell_check_with_options(text, &HashMap::new()).await
}
/// Run spell check with custom options
pub async fn spell_check_with_options(
&self,
text: &str,
options: HashMap<GramOpt, bool>,
options: &HashMap<GramOpt, bool>,
) -> Result<CheckResult, Box<dyn Error>> {
let url = format!("{}/gc_text/fr", self.base_url);
log::debug!("Will use URL {} for spell check", url);
@ -421,7 +421,7 @@ mod test {
opts.insert(GramOpt::EspacesInsecables, false);
let res = GrammalecteClient::start_server()
.unwrap()
.spell_check_with_options(msg, opts)
.spell_check_with_options(msg, &opts)
.await
.unwrap();
println!("RESULT = {:#?}", res);

View File

@ -50,6 +50,7 @@ impl EmbeddedServer {
.arg("-p")
.arg(port.to_string())
.stdout(Stdio::null())
.stderr(Stdio::null())
.spawn()?;
wait_for_port(port)?;