pub struct ServerClient {
pub api: String,
pub client: Client,
/* private fields */
}
Expand description
Client to communicate with the LanguageTool
server using async requests.
Fields§
§api: String
API string: hostname and, optionally, port number (see ServerCli
).
client: Client
Reqwest client that can send requests to the server.
Implementations§
Source§impl ServerClient
impl ServerClient
Sourcepub fn new(hostname: &str, port: &str) -> Self
pub fn new(hostname: &str, port: &str) -> Self
Construct a new server client using hostname and (optional) port
An empty string is accepeted as empty port.
For port validation, please use parse_port
as this constructor does
not check anything.
Sourcepub fn with_max_suggestions(self, max_suggestions: isize) -> Self
pub fn with_max_suggestions(self, max_suggestions: isize) -> Self
Set the maximum number of suggestions (defaults to -1), a negative number will keep all replacement suggestions.
Sourcepub async fn check(&self, request: &CheckRequest) -> Result<CheckResponse>
pub async fn check(&self, request: &CheckRequest) -> Result<CheckResponse>
Send a check request to the server and await for the response.
Sourcepub async fn check_multiple_and_join(
&self,
requests: Vec<CheckRequest>,
) -> Result<CheckResponse>
Available on crate feature multithreaded
only.
pub async fn check_multiple_and_join( &self, requests: Vec<CheckRequest>, ) -> Result<CheckResponse>
multithreaded
only.Send multiple check requests and join them into a single response.
§Error
If any of the requests has self.text
field which is none.
Sourcepub async fn annotate_check(
&self,
request: &CheckRequest,
origin: Option<&str>,
color: bool,
) -> Result<String>
Available on crate feature annotate
only.
pub async fn annotate_check( &self, request: &CheckRequest, origin: Option<&str>, color: bool, ) -> Result<String>
annotate
only.Send a check request to the server, await for the response and annotate it.
Sourcepub async fn languages(&self) -> Result<LanguagesResponse>
pub async fn languages(&self) -> Result<LanguagesResponse>
Send a languages request to the server and await for the response.
Sourcepub async fn words(&self, request: &WordsRequest) -> Result<WordsResponse>
pub async fn words(&self, request: &WordsRequest) -> Result<WordsResponse>
Send a words request to the server and await for the response.
Sourcepub async fn words_add(
&self,
request: &WordsAddRequest,
) -> Result<WordsAddResponse>
pub async fn words_add( &self, request: &WordsAddRequest, ) -> Result<WordsAddResponse>
Send a words/add request to the server and await for the response.
Sourcepub async fn words_delete(
&self,
request: &WordsDeleteRequest,
) -> Result<WordsDeleteResponse>
pub async fn words_delete( &self, request: &WordsDeleteRequest, ) -> Result<WordsDeleteResponse>
Send a words/delete request to the server and await for the response.
Source§impl ServerClient
impl ServerClient
Sourcepub fn from_env() -> Result<Self>
pub fn from_env() -> Result<Self>
Create a new ServerClient
instance from environ variables.
See ServerCli::from_env
for more details.
Sourcepub fn from_env_or_default() -> Self
pub fn from_env_or_default() -> Self
Create a new ServerClient
instance from environ variables,
but defaults to ServerClient::default
if expected environ
variables are not set.
Trait Implementations§
Source§impl Clone for ServerClient
impl Clone for ServerClient
Source§fn clone(&self) -> ServerClient
fn clone(&self) -> ServerClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more