pub struct RequestBuilder<'a> { /* private fields */ }
Expand description
Use this struct to build requests to send to the Datamuse api. This request can be sent either by building it into a Request with build() and then using the send() method on the resulting Request or using send() to send it directly. Note that not all parameters can be used for each vocabulary and endpoint
Implementations§
Source§impl<'a> RequestBuilder<'a>
impl<'a> RequestBuilder<'a>
Sourcepub fn means_like(self, word: &str) -> Self
pub fn means_like(self, word: &str) -> Self
Sets a query parameter for words which have a similar meaning to the given word
Sourcepub fn sounds_like(self, word: &str) -> Self
pub fn sounds_like(self, word: &str) -> Self
Sets a query parameter for words which sound similar to the given word
Sourcepub fn spelled_like(self, word: &str) -> Self
pub fn spelled_like(self, word: &str) -> Self
Sets a query parameter for words which have a similar spelling to the given word. This parameter allows for wildcard charcters with ‘?’ matching a single letter and ‘*’ matching any number of letters
Sets a query parameter for words which are related to the given word. The various options for relations are given in the RelatedType enum. See its documentation for more information on the options. Note that this is currently not available for the Spanish vocabulary set
Sourcepub fn add_topic(self, word: &str) -> Self
pub fn add_topic(self, word: &str) -> Self
Sets a query parameter for words which fall under the topic of the given word. Multiple topics can be specified at once, however requests are limited to five topics and as such any specified over this limit will be ignored
Sourcepub fn left_context(self, word: &str) -> Self
pub fn left_context(self, word: &str) -> Self
Sets a query parameter to refer to the word directly before the main query term
Sourcepub fn right_context(self, word: &str) -> Self
pub fn right_context(self, word: &str) -> Self
Sets a query parameter to refer to the word directly after the main query term
Sourcepub fn max_results(self, maximum: u16) -> Self
pub fn max_results(self, maximum: u16) -> Self
The maximum number of results that should be returned. By default this is set to 100 and it can be increased to a maximum of 1000. This parameter is also allowed for the “suggest” endpoint
Sourcepub fn meta_data(self, flag: MetaDataFlag) -> Self
pub fn meta_data(self, flag: MetaDataFlag) -> Self
Sets a metadata flag to specify data returned with each word. The various options for flags are given in the MetaDataFlag enum. See its documentation for more information on the options
Sourcepub fn hint_string(self, hint: &str) -> Self
pub fn hint_string(self, hint: &str) -> Self
Sets the hint string for the “suggest” endpoint. Note that this is not allowed for the “words” endpoint
Sourcepub fn build(&self) -> Result<Request<'_>>
pub fn build(&self) -> Result<Request<'_>>
Converts the RequestBuilder into a Request which can be executed by calling the send() method on it. This method will return an error if any of the given parameters have not been used correctly or the underlying call to reqwest to build the request fails
Sourcepub async fn send(&self) -> Result<Response>
pub async fn send(&self) -> Result<Response>
A convenience method to build and send the request in one step. The resulting response can be parsed with its list() method
Sourcepub async fn list(&self) -> Result<Vec<WordElement>>
pub async fn list(&self) -> Result<Vec<WordElement>>
A convenience method to build and send the request as well as parse the json in one step