mod client;
mod error;
mod multipart;
mod ratelimiting;
mod request;
mod routing;
mod typing;
use std::sync::Arc;
use reqwest::Method;
pub use reqwest::StatusCode;
pub use self::client::*;
pub use self::error::*;
pub use self::multipart::*;
pub use self::ratelimiting::*;
pub use self::request::*;
pub use self::routing::*;
pub use self::typing::*;
#[cfg(feature = "cache")]
use crate::cache::Cache;
#[cfg(feature = "client")]
use crate::client::Context;
use crate::model::prelude::*;
pub trait CacheHttp: Send + Sync {
fn http(&self) -> &Http;
#[cfg(feature = "cache")]
#[must_use]
fn cache(&self) -> Option<&Arc<Cache>> {
None
}
}
impl<T> CacheHttp for &T
where
T: CacheHttp,
{
fn http(&self) -> &Http {
(*self).http()
}
#[cfg(feature = "cache")]
fn cache(&self) -> Option<&Arc<Cache>> {
(*self).cache()
}
}
impl<T> CacheHttp for Arc<T>
where
T: CacheHttp,
{
fn http(&self) -> &Http {
(**self).http()
}
#[cfg(feature = "cache")]
fn cache(&self) -> Option<&Arc<Cache>> {
(**self).cache()
}
}
#[cfg(feature = "client")]
impl CacheHttp for Context {
fn http(&self) -> &Http {
&self.http
}
#[cfg(feature = "cache")]
fn cache(&self) -> Option<&Arc<Cache>> {
Some(&self.cache)
}
}
#[cfg(feature = "cache")]
impl CacheHttp for (&Arc<Cache>, &Http) {
fn cache(&self) -> Option<&Arc<Cache>> {
Some(self.0)
}
fn http(&self) -> &Http {
self.1
}
}
impl CacheHttp for Http {
fn http(&self) -> &Http {
self
}
}
#[cfg(feature = "cache")]
impl AsRef<Cache> for (&Arc<Cache>, &Http) {
fn as_ref(&self) -> &Cache {
self.0
}
}
#[cfg(feature = "cache")]
impl AsRef<Http> for (&Arc<Cache>, &Http) {
fn as_ref(&self) -> &Http {
self.1
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum LightMethod {
Delete,
Get,
Patch,
Post,
Put,
}
impl LightMethod {
#[must_use]
pub const fn reqwest_method(self) -> Method {
match self {
Self::Delete => Method::DELETE,
Self::Get => Method::GET,
Self::Patch => Method::PATCH,
Self::Post => Method::POST,
Self::Put => Method::PUT,
}
}
}
#[non_exhaustive]
pub enum GuildPagination {
After(GuildId),
Before(GuildId),
}
#[non_exhaustive]
pub enum UserPagination {
After(UserId),
Before(UserId),
}
#[derive(Clone, Copy, Debug)]
#[non_exhaustive]
pub enum MessagePagination {
After(MessageId),
Around(MessageId),
Before(MessageId),
}