Trait skua::http::CacheHttp

source ·
pub trait CacheHttp: Send + Sync {
    // Required method
    fn http(&self) -> &Http;

    // Provided method
    fn cache(&self) -> Option<&Arc<Cache>> { ... }
}
Available on crate feature http only.
Expand description

This trait will be required by functions that need Http and can optionally use a Cache to potentially avoid REST-requests.

The types Context and Http implement this trait and thus passing these to functions expecting impl CacheHttp is possible. For the full list of implementations, see the Implementors and Implementations on Foreign Types section in the generated docs.

In a situation where you have the cache-feature enabled but you do not pass a cache, the function will behave as if no cache-feature is active.

If you are calling a function that expects impl CacheHttp as argument and you wish to utilise the cache-feature but you got no access to a Context, you can pass a tuple of (&Arc<Cache>, &Http).

Required Methods§

source

fn http(&self) -> &Http

Provided Methods§

source

fn cache(&self) -> Option<&Arc<Cache>>

Available on crate feature cache only.

Implementations on Foreign Types§

source§

impl CacheHttp for (&Arc<Cache>, &Http)

Available on crate feature cache only.
source§

fn cache(&self) -> Option<&Arc<Cache>>

source§

fn http(&self) -> &Http

source§

impl<T> CacheHttp for &T
where T: CacheHttp,

source§

fn http(&self) -> &Http

source§

fn cache(&self) -> Option<&Arc<Cache>>

Available on crate feature cache only.
source§

impl<T> CacheHttp for Arc<T>
where T: CacheHttp,

source§

fn http(&self) -> &Http

source§

fn cache(&self) -> Option<&Arc<Cache>>

Available on crate feature cache only.

Implementors§

source§

impl CacheHttp for Context

Available on crate feature client only.
source§

impl CacheHttp for Http