aboutsummaryrefslogtreecommitdiff
path: root/azalea-client/src/account/offline.rs
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2026-01-01 22:28:53 -0600
committerGitHub <noreply@github.com>2026-01-01 22:28:53 -0600
commit1ca1f1d9e27aeea3adaf359570f2e211e0a9af74 (patch)
treedd35bb9bff67f0622a6410c99b5bd1678c9c8299 /azalea-client/src/account/offline.rs
parent7b84235a9be5bdc7c05873467ad8310b57448d79 (diff)
downloadazalea-drasl-1ca1f1d9e27aeea3adaf359570f2e211e0a9af74.tar.xz
Extensible Account (#301)
* refactor Account * clean up implementation and docs * add AccountTrait::join * update changelog * update example
Diffstat (limited to 'azalea-client/src/account/offline.rs')
-rw-r--r--azalea-client/src/account/offline.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/azalea-client/src/account/offline.rs b/azalea-client/src/account/offline.rs
new file mode 100644
index 00000000..f0ee49bd
--- /dev/null
+++ b/azalea-client/src/account/offline.rs
@@ -0,0 +1,37 @@
+use uuid::Uuid;
+
+use crate::account::{Account, AccountTrait};
+
+/// A type of account that does not perform any authentication and cannot join
+/// online-mode servers.
+///
+/// This type is not intended to be used directly by the user. To actually make
+/// an offline-mode account, see [`Account::offline`].
+#[derive(Debug)]
+pub struct OfflineAccount {
+ username: String,
+}
+impl AccountTrait for OfflineAccount {
+ fn username(&self) -> &str {
+ &self.username
+ }
+ fn uuid(&self) -> Uuid {
+ azalea_crypto::offline::generate_uuid(&self.username)
+ }
+ fn access_token(&self) -> Option<String> {
+ None
+ }
+}
+
+impl Account {
+ /// An offline account does not authenticate with Microsoft's servers, and
+ /// as such can only join offline mode servers.
+ ///
+ /// This is useful for testing in LAN worlds.
+ pub fn offline(username: &str) -> Self {
+ OfflineAccount {
+ username: username.to_owned(),
+ }
+ .into()
+ }
+}