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 accepted 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: &Request<'_>) -> Result<Response>
pub async fn check(&self, request: &Request<'_>) -> Result<Response>
Send a check request to the server and await for the response.
Sourcepub async fn check_multiple_and_join<'source>(
&self,
requests: Vec<Request<'source>>,
) -> Result<ResponseWithContext<'source>>
Available on crate feature multithreaded
only.
pub async fn check_multiple_and_join<'source>( &self, requests: Vec<Request<'source>>, ) -> Result<ResponseWithContext<'source>>
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, or
if zero request is provided.
Sourcepub async fn check_multiple_and_join_without_context(
&self,
requests: Vec<Request<'_>>,
) -> Result<Response>
Available on crate feature multithreaded
only.
pub async fn check_multiple_and_join_without_context( &self, requests: Vec<Request<'_>>, ) -> Result<Response>
multithreaded
only.Sourcepub async fn annotate_check(
&self,
request: &Request<'_>,
origin: Option<&str>,
color: bool,
) -> Result<String>
Available on crate feature annotate
only.
pub async fn annotate_check( &self, request: &Request<'_>, 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<Response>
pub async fn languages(&self) -> Result<Response>
Send a languages request to the server and await for the response.
Sourcepub async fn words(&self, request: &Request) -> Result<Response>
pub async fn words(&self, request: &Request) -> Result<Response>
Send a words request to the server and await for the response.
Sourcepub async fn words_add(&self, request: &Request) -> Result<Response>
pub async fn words_add(&self, request: &Request) -> Result<Response>
Send a words/add request to the server and await for the response.
Sourcepub async fn words_delete(&self, request: &Request) -> Result<Response>
pub async fn words_delete(&self, request: &Request) -> Result<Response>
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 moreSource§impl Debug for ServerClient
impl Debug for ServerClient
Source§impl Default for ServerClient
impl Default for ServerClient
Auto Trait Implementations§
impl Freeze for ServerClient
impl !RefUnwindSafe for ServerClient
impl Send for ServerClient
impl Sync for ServerClient
impl Unpin for ServerClient
impl !UnwindSafe for ServerClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more