Minor doc changes
This commit is contained in:
parent
1e81a2682f
commit
ede965411e
|
@ -34,6 +34,7 @@ pub struct UrlBundle {
|
|||
}
|
||||
|
||||
impl UrlBundle {
|
||||
/// Creates a new UrlBundle from the relevant urls.
|
||||
pub fn new(api: String, wss: String, cdn: String) -> Self {
|
||||
Self {
|
||||
api: UrlBundle::parse_url(api),
|
||||
|
|
|
@ -6,6 +6,7 @@ use crate::types::Snowflake;
|
|||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
/// A schema used to modify a user.
|
||||
pub struct UserModifySchema {
|
||||
pub username: Option<String>,
|
||||
pub avatar: Option<String>,
|
||||
|
@ -19,6 +20,8 @@ pub struct UserModifySchema {
|
|||
pub discriminator: Option<i16>,
|
||||
}
|
||||
|
||||
/// A schema used to create a private channel.
|
||||
///
|
||||
/// # Attributes:
|
||||
/// - recipients: The users to include in the private channel
|
||||
/// - access_tokens: The access tokens of users that have granted your app the `gdm.join` scope. Only usable for OAuth2 requests (which can only create group DMs).
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#[allow(missing_docs)]
|
||||
use crate::types::utils::Snowflake;
|
||||
use jsonwebtoken::{encode, EncodingKey, Header};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::types::utils::Snowflake;
|
||||
|
||||
pub fn generate_token(id: &Snowflake, email: String, jwt_key: &str) -> String {
|
||||
let claims = Claims::new(&email, id);
|
||||
|
||||
|
@ -11,7 +11,9 @@ pub fn generate_token(id: &Snowflake, email: String, jwt_key: &str) -> String {
|
|||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Claims {
|
||||
/// When the token expires, unix epoch
|
||||
pub exp: i64,
|
||||
/// When the token was issued
|
||||
pub iat: i64,
|
||||
pub email: String,
|
||||
pub id: String,
|
||||
|
|
|
@ -18,6 +18,7 @@ const EPOCH: i64 = 1420070400000;
|
|||
pub struct Snowflake(u64);
|
||||
|
||||
impl Snowflake {
|
||||
/// Generates a snowflake for the current epoch.
|
||||
pub fn generate() -> Self {
|
||||
const WORKER_ID: u64 = 0;
|
||||
const PROCESS_ID: u64 = 1;
|
||||
|
@ -31,6 +32,7 @@ impl Snowflake {
|
|||
Self(time as u64 | worker | process | increment)
|
||||
}
|
||||
|
||||
/// Returns the snowflake's timestamp
|
||||
pub fn timestamp(self) -> DateTime<Utc> {
|
||||
Utc.timestamp_millis_opt((self.0 >> 22) as i64 + EPOCH)
|
||||
.unwrap()
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
|
||||
//! Where the voice chat implementation will be, once it's finished.
|
||||
//! For development on voice, see the feature/voice branch.
|
||||
|
|
Loading…
Reference in New Issue