-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API change proposal for Songbird::join and Songbird::join_gateway #65
Comments
As a real world example async fn _join(&self, channel_id: ChannelId) -> Result<()> {
let call = self.bot.songbird.get_or_insert(self.guild_id.into());
{
let mut lock = call.lock().await;
if !lock.is_deaf() {
lock.deafen(true).await?
}
}
let (_, result) = self.bot.songbird.join(self.guild_id, channel_id).await;
result would turn into this: async fn _join(&self, channel_id: ChannelId) -> Result<()> {
let call = self.bot.songbird.get_or_insert(self.guild_id.into());
{
let mut lock = call.lock().await;
if !lock.is_deaf() {
lock.deafen(true).await?
}
}
self.bot.songbird.join(channel_id, call).await
} |
I agree that being unable to just use There might be cause for moving out the logic in impl Call {
pub fn join_from_lock(self: &Arc<Mutex<Self>>) -> JoinResult<()> {
// Safe handling of lock, await one, unlock, await other...
}
} ...and then pushing users to prefer Songbird::join == Call::join_from_lock > Call::join. |
Didn't think about new users fallaciously using |
It's not an unsafe method; there are just caveats to using a |
Another option is to not return |
Replaces the annoying dual-return (i.e., created `Call` *and* `Result<x>`) with a single `Return<Call/ConnectionInfo>`. Users are now informed via that a `Call` is created -- thus, cleanup in event of connection failure is now their responsibility. Tested using `cargo make ready`. Closes serenity-rs#65.
Replaces the annoying dual-return (i.e., created `Call` *and* `Result<x>`) with a single `Return<Call/ConnectionInfo>`. Users are now informed via that a `Call` is created -- thus, cleanup in event of connection failure is now their responsibility. Tested using `cargo make ready`. Closes #65.
Not being able to use
?
onSongbird::join
andSongbird::join_gateway
is bothering me, so I propose that join takes a call as an argument instead of returning a new one.so
would be
Thoughts?
The text was updated successfully, but these errors were encountered: