[−][src]Struct urbandictionary::Client
Methods
impl Client
[src]
pub fn new(http_client: impl Into<Arc<HttpClient>>) -> Self
[src]
Create a new UrbanDictionary client.
Examples
use reqwest::Client as HttpClient; use urbandictionary::Client; let http_client = HttpClient::new(); let urban_client = Client::new(http_client);
pub async fn define<'_, '_>(
&'_ self,
word: &'_ str
) -> Result<Option<Definition>>
[src]
&'_ self,
word: &'_ str
) -> Result<Option<Definition>>
Attempt to retrieve the first definition for a word.
Examples
Retrieve the definition of the word "cat"
:
use reqwest::Client as HttpClient; use urbandictionary::Client; let http_client = HttpClient::new(); let client = Client::new(http_client); let response = client.define("cat").await?; if let Some(definition) = response { println!("The definition of cat is: {}", definition.definition); } else { println!("No definition found"); }
pub async fn definitions<'_, '_>(&'_ self, word: &'_ str) -> Result<Response>
[src]
Attempt to retrieve the definitions for a word.
Examples
Retrieve the definitions for the word "cat"
:
use reqwest::Client as HttpClient; use urbandictionary::Client; let http_client = HttpClient::new(); let client = Client::new(http_client); let response = client.definitions("cat").await?; if let Some(definition) = response.definitions.first() { println!( "The first definition of cat is: {}", definition.definition, ); } else { println!("No definitions found"); }
Auto Trait Implementations
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
impl !RefUnwindSafe for Client
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,