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]] [[package]]
name = "grammalecte_client" name = "grammalecte_client"
version = "0.1.0" version = "0.1.1"
dependencies = [ dependencies = [
"env_logger", "env_logger",
"log", "log",

View File

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

View File

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