Skip to content

Commit

Permalink
Improve docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
bloodnighttw committed Jul 12, 2024
1 parent 6d71b9f commit 7b6d83e
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions reginleif/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ mod test{
println!("{:?}",xbox_live_token);
let xbox_security_token = XboxSecurityToken::fetch(&client,xbox_live_token).await.unwrap();
println!("{:?}",xbox_security_token);

let minecraft_auth = MinecraftAuth::fetch(&client,xbox_security_token).await.unwrap();
println!("{:?}",minecraft_auth);
let profile = Profile::fetch(&client,&minecraft_auth).await.unwrap();
Expand All @@ -73,7 +73,7 @@ mod test{
res.refresh(&(client,client_id.to_string())).await.unwrap();

assert_ne!(cloned.created_at,res.created_at);


}

Expand Down
5 changes: 5 additions & 0 deletions reginleif/src/auth/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ impl Expirable for Account{
}
}

/// Refreshable
///
/// Implement this trait means you can refresh the data of the struct.
/// This will be used in [ExpiringData](crate::utils::expiring_data::ExpiringData) to refresh the Account Data,
/// include Minecraft Auth, Profile, and Microsoft Auth (if it's expired).
#[async_trait]
impl Refreshable for Account{

Expand Down
19 changes: 19 additions & 0 deletions reginleif/src/auth/minecraft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ use crate::utils::serde_convert::{duration_to_sec, sec_to_duration};
/// This struct is used to authenticate the user with Minecraft Auth Server.
#[derive(Serialize, Deserialize,Debug,Clone, Expirable, NoRefresh)]
pub struct MinecraftAuth {

/// UUID of MinecraftAuth, note this is **NOT** the UUID of the player.
pub username: String,
/// The access token you can use to access Minecraft.
pub access_token: String,

/// The expires time of the access token.
#[serde(deserialize_with = "sec_to_duration", serialize_with = "duration_to_sec")]
#[dur]
pub expires_in: Duration,
/// The token type of the access token. Always being "bearer"
pub token_type: String,
}

Expand Down Expand Up @@ -54,9 +60,14 @@ impl MinecraftAuth{
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Profile {

/// uuid of the player
pub id: String,
/// name of the player
pub name: String,
/// the skins of the player
pub skins: Vec<Skin>,
/// the capes of the player have
pub capes: Vec<Caps>,
}

Expand Down Expand Up @@ -88,19 +99,27 @@ impl Profile{
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Skin {
/// the id of the skin
pub id: String,
/// ACTIVE or INACTIVE
pub state: String,
/// the url of the skin you can get.
pub url: String,
pub texture_key: String,
/// Classic or Slim
pub variant: String,
}

/// Minecraft Capes
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Caps {
/// the id of the cape
pub id: String,
/// ACTIVE or INACTIVE
pub state: String,
/// the url of the cape you can get.
pub url: String,
/// the alias of the cape
pub alias: String,
}
2 changes: 2 additions & 0 deletions reginleif/src/auth/xbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ impl From<(&str,&str)> for XboxSecurityToken{
}
}


/// The error that can occur while fetching Xbox Security Token.
#[derive(Error,Debug)]
pub enum XboxSecurityError{
#[error("The account doesn't have an Xbox account. Once they sign up for one (or login through minecraft.net to create one) then they can proceed with the login")]
Expand Down
2 changes: 2 additions & 0 deletions reginleif/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/// All the thing that related to Minecraft service.
pub mod auth;
/// All the thing that related to utils that is need across the package.
pub mod utils;

0 comments on commit 7b6d83e

Please sign in to comment.