[][src]Struct ksoft::images::Images

pub struct Images {
    pub http: Arc<HttpClient>,
}

Fields

http: Arc<HttpClient>

Implementations

impl Images[src]

pub fn new(http_client: Arc<HttpClient>) -> Self[src]

pub async fn random_image<'_>(
    &'_ self,
    tag: impl ToString,
    nsfw: bool
) -> HttpResult<Image, ImageError>
[src]

Gets a random image based in a given tag

Example

This example is not tested
if let Ok(res) = client.images.random_image("doge", false).await {
    match res {
        Ok(image) => {
            //do something with the image
        },
        Err(why) => {
            //do something with the <ImageError> struct
        }
    }
}

pub async fn random_meme<'_>(&'_ self) -> Result<RedditImage>[src]

Gets a random meme from reddit

Example

This example is not tested
if let Ok(meme) = client.images.random_meme().await {
    //do something here
}

pub async fn random_aww<'_>(&'_ self) -> Result<RedditImage>[src]

Gets a random cute image

Example

This example is not tested
if let Ok(aww) = client.images.random_aww().await {
    //do something with the image
}

pub async fn random_reddit<'_>(
    &'_ self,
    subreddit: impl ToString,
    remove_nsfw: bool,
    span: SpanType
) -> HttpResult<RedditImage, ImageError>
[src]

Gets a random post from a given subreddit

Example

This example is not tested
if let Ok(res) = client.images.random_reddit("Technology", true, SpanType::Day).await {
    match res {
        Ok(red) => {
            //do something with the reddit image
        },
        Err(why) => {
            //do something with the <ImageError> struct
        }
    }
}

pub async fn random_wikihow<'_>(&'_ self, nsfw: bool) -> Result<WikiHowImage>[src]

Gets a random WikiHow image

Example

This example is not tested
if let Ok(wiki_image) = client.images.random_wikihow(false).await {
    //do something with the image
}

pub async fn get_tags<'_>(&'_ self) -> Result<TagList>[src]

Gets a list of all tags available

Example

if let Ok(tags) = client.images.get_tags().await { //do something with all tags }

pub async fn get_image<'_>(
    &'_ self,
    sf: impl AsRef<str>
) -> HttpResult<Image, ImageError>
[src]

Gets an image using its Snowflake

Example

This example is not tested
if let Ok(res) = client.images.get_image("i-8ta8p52f-27").await {

pub async fn get_tag<'_>(&'_ self, tag: impl AsRef<str>) -> Result<TagList>[src]

Get a tag using its name

Example

This example is not tested
if let Ok(tag) = client.images.get_tag("doge").await {
    //do something with the tag
}

pub async fn random_nsfw<'_>(&'_ self, gifs: bool) -> Result<RedditImage>[src]

Get a random NSFW image

Example

This example is not tested
if let Ok(nsfw) = client.images.random_nsfw(true).await {
    //do something with the image
}

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.