You've already forked AstralRinth
forked from didirus/AstralRinth
Create schema for the API (#28)
* feat(schema): add basic structs for schema * feat(schema): implement base62 id parsing * docs(schema): add documentation for schema structs fix(schema): prevent integer overflow in base62 decoding * refactor(schema): move ids into submodules, reexport from ids mod * feat(schema): add random generation of base62 ids style: run rustfmt
This commit is contained in:
33
src/models/teams.rs
Normal file
33
src/models/teams.rs
Normal file
@@ -0,0 +1,33 @@
|
||||
use super::ids::Base62Id;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// The ID of a specific user, encoded as base62 for usage in the API
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(from = "Base62Id")]
|
||||
#[serde(into = "Base62Id")]
|
||||
pub struct UserId(pub u64);
|
||||
|
||||
/// The ID of a team
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(from = "Base62Id")]
|
||||
#[serde(into = "Base62Id")]
|
||||
pub struct TeamId(pub u64);
|
||||
|
||||
// TODO: permissions, role names, etc
|
||||
/// A team of users who control a mod
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct Team {
|
||||
/// The id of the team
|
||||
pub id: TeamId,
|
||||
/// A list of the members of the team
|
||||
pub members: Vec<TeamMember>,
|
||||
}
|
||||
|
||||
/// A member of a team
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct TeamMember {
|
||||
/// The ID of the user associated with the member
|
||||
pub user_id: UserId,
|
||||
/// The name of the user
|
||||
pub name: String,
|
||||
}
|
||||
Reference in New Issue
Block a user