aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShayne Hartford <shaybox@shaybox.com>2024-11-20 23:43:21 -0500
committerGitHub <noreply@github.com>2024-11-20 22:43:21 -0600
commita8125cd198832ee46f9e76e8e9d09cf5780ad4c4 (patch)
tree6232f216b9fe4720e54e2eab46510550260b29a9
parent3cf17cb89601cc4de3db23a8c9ae25f313e01aa3 (diff)
downloadazalea-drasl-a8125cd198832ee46f9e76e8e9d09cf5780ad4c4.tar.xz
Add SwarmBuilder::add_account_with_opts (#185)
-rw-r--r--azalea/src/swarm/mod.rs19
1 files changed, 16 insertions, 3 deletions
diff --git a/azalea/src/swarm/mod.rs b/azalea/src/swarm/mod.rs
index 8c2d23f6..e9644799 100644
--- a/azalea/src/swarm/mod.rs
+++ b/azalea/src/swarm/mod.rs
@@ -232,8 +232,8 @@ where
/// clients to have different default states, add them one at a time with
/// [`Self::add_account_with_state`].
///
- /// By default every account will join at the same time, you can add a delay
- /// with [`Self::join_delay`].
+ /// By default, every account will join at the same time, you can add a
+ /// delay with [`Self::join_delay`].
#[must_use]
pub fn add_accounts(mut self, accounts: Vec<Account>) -> Self
where
@@ -242,8 +242,10 @@ where
for account in accounts {
self = self.add_account(account);
}
+
self
}
+
/// Add a single new [`Account`] to the swarm. Use [`Self::add_accounts`] to
/// add multiple accounts at a time.
///
@@ -254,8 +256,9 @@ where
where
S: Default,
{
- self.add_account_with_state(account, S::default())
+ self.add_account_with_state_and_opts(account, S::default(), JoinOpts::default())
}
+
/// Add an account with a custom initial state. Use just
/// [`Self::add_account`] to use the Default implementation for the state.
#[must_use]
@@ -263,6 +266,16 @@ where
self.add_account_with_state_and_opts(account, state, JoinOpts::default())
}
+ /// Add an account with a custom initial state. Use just
+ /// [`Self::add_account`] to use the Default implementation for the state.
+ #[must_use]
+ pub fn add_account_with_opts(self, account: Account, opts: JoinOpts) -> Self
+ where
+ S: Default,
+ {
+ self.add_account_with_state_and_opts(account, S::default(), opts)
+ }
+
/// Same as [`Self::add_account_with_state`], but allow passing in custom
/// join options.
#[must_use]