AccountTrait

Trait AccountTrait 

Source
pub trait AccountTrait:
    Send
    + Sync
    + Debug {
    // Required methods
    fn username(&self) -> &str;
    fn uuid(&self) -> Uuid;
    fn access_token(&self) -> Option<String>;

    // Provided methods
    fn refresh(
        &self,
    ) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + '_>> { ... }
    fn certs(&self) -> Option<Certificates> { ... }
    fn set_certs(&self, certs: Certificates) { ... }
    fn join<'a>(
        &'a self,
        public_key: &'a [u8],
        private_key: &'a [u8; 16],
        server_id: &'a str,
        proxy: Option<Proxy>,
    ) -> Pin<Box<dyn Future<Output = Result<(), ClientSessionServerError>> + Send + 'a>> { ... }
}
Expand description

A trait that all types of accounts implement.

This can be used, for example, to join servers with a custom authentication server.

Anything that implements AccountTrait can be converted to an Account with .into().

Consider reading the source code of MicrosoftAccount for an example of how to implement this.

Required Methods§

Source

fn username(&self) -> &str

Returns the Minecraft username of the account.

Source

fn uuid(&self) -> Uuid

Returns the unique identifier for this player.

For offline-mode accounts, this UUID is generated by calling azalea_crypto::offline::generate_uuid.

Source

fn access_token(&self) -> Option<String>

The access token for authentication.

You can obtain one of these manually from azalea-auth.

Provided Methods§

Source

fn refresh( &self, ) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + '_>>

Refreshes the access token for this account.

Source

fn certs(&self) -> Option<Certificates>

Source

fn set_certs(&self, certs: Certificates)

Override the chat signing certificates for this account.

You can get the certificates needed for this from azalea_auth::certs::fetch_certificates. You typically don’t need to call this yourself, as Azalea will do it for you.

For accounts that don’t support signing (i.e. offline-mode), this won’t do anything.

Source

fn join<'a>( &'a self, public_key: &'a [u8], private_key: &'a [u8; 16], server_id: &'a str, proxy: Option<Proxy>, ) -> Pin<Box<dyn Future<Output = Result<(), ClientSessionServerError>> + Send + 'a>>

Typically used to tell Mojang’s sessionserver that we are going to join a server.

This must be implemented for accounts that can join online-mode servers.

This function is called internally by Azalea when the account tries to join a server, but only if AccountTrait::access_token is Some.

Implementors§