pub mod client;
pub mod error;
pub mod multipart;
pub mod ratelimiting;
pub mod request;
pub mod routing;
pub mod typing;
mod utils;
use std::sync::Arc;
use reqwest::Method;
pub use reqwest::StatusCode;
pub use self::client::*;
pub use self::error::Error as HttpError;
use self::request::Request;
pub use self::typing::*;
#[cfg(feature = "cache")]
use crate::cache::Cache;
#[cfg(feature = "client")]
use crate::client::Context;
use crate::model::prelude::*;
#[cfg(feature = "client")]
use crate::CacheAndHttp;
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 = "client")]
impl CacheHttp for CacheAndHttp {
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 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),
}