Skip to content

Commit

Permalink
Add SwarmBuilder::add_account_with_opts (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShayBox authored Nov 21, 2024
1 parent 3cf17cb commit a8125cd
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions azalea/src/swarm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
///
Expand All @@ -254,15 +256,26 @@ 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]
pub fn add_account_with_state(self, account: Account, state: S) -> Self {
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]
Expand Down

0 comments on commit a8125cd

Please sign in to comment.