Skip to content
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

feat(gateway)!: Constructors take String, not Into<String> #1481

Merged
merged 2 commits into from
Jan 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions gateway/src/cluster/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub struct ClusterBuilder(ClusterConfig, ShardBuilder);

impl ClusterBuilder {
/// Create a new builder to construct and configure a cluster.
pub fn new(token: impl Into<String>, intents: Intents) -> Self {
pub fn new(token: String, intents: Intents) -> Self {
Self(
ClusterConfig {
shard_scheme: ShardScheme::Auto,
Expand Down Expand Up @@ -249,8 +249,8 @@ impl ClusterBuilder {
}
}

impl<T: Into<String>> From<(T, Intents)> for ClusterBuilder {
fn from((token, intents): (T, Intents)) -> Self {
impl From<(String, Intents)> for ClusterBuilder {
fn from((token, intents): (String, Intents)) -> Self {
Self::new(token, intents)
}
}
Expand Down
7 changes: 2 additions & 5 deletions gateway/src/cluster/impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,7 @@ impl Cluster {
/// there was an HTTP error Retrieving the gateway information.
///
/// [`builder`]: Self::builder
pub async fn new(
token: impl Into<String>,
intents: Intents,
) -> Result<(Self, Events), ClusterStartError> {
pub async fn new(token: String, intents: Intents) -> Result<(Self, Events), ClusterStartError> {
Self::builder(token, intents).build().await
}

Expand Down Expand Up @@ -388,7 +385,7 @@ impl Cluster {
/// }
/// # Ok(()) }
/// ```
pub fn builder(token: impl Into<String>, intents: Intents) -> ClusterBuilder {
pub fn builder(token: String, intents: Intents) -> ClusterBuilder {
ClusterBuilder::new(token, intents)
}

Expand Down
13 changes: 5 additions & 8 deletions gateway/src/shard/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,7 @@ impl ShardBuilder {
/// Create a new builder to configure and construct a shard.
///
/// Refer to each method to learn their default values.
pub fn new(token: impl Into<String>, intents: Intents) -> Self {
Self::_new(token.into(), intents)
}

fn _new(mut token: String, intents: Intents) -> Self {
pub fn new(mut token: String, intents: Intents) -> Self {
if !token.starts_with("Bot ") {
token.insert_str(0, "Bot ");
}
Expand Down Expand Up @@ -319,14 +315,15 @@ impl ShardBuilder {
/// commands":
///
/// ```no_run
/// use std::env;
/// use twilight_gateway::{Intents, Shard};
/// use twilight_model::gateway::{
/// payload::outgoing::update_presence::UpdatePresencePayload,
/// presence::{ActivityType, MinimalActivity, Status},
/// };
///
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
/// let shard = Shard::builder("token", Intents::empty())
/// let shard = Shard::builder(env::var("DISCORD_TOKEN")?, Intents::empty())
/// .presence(UpdatePresencePayload::new(
/// vec![MinimalActivity {
/// kind: ActivityType::Playing,
Expand Down Expand Up @@ -413,8 +410,8 @@ impl ShardBuilder {
}
}

impl<T: Into<String>> From<(T, Intents)> for ShardBuilder {
fn from((token, intents): (T, Intents)) -> Self {
impl From<(String, Intents)> for ShardBuilder {
fn from((token, intents): (String, Intents)) -> Self {
Self::new(token, intents)
}
}
Expand Down
4 changes: 2 additions & 2 deletions gateway/src/shard/impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ impl Shard {
/// ```
///
/// [`start`]: Self::start
pub fn new(token: impl Into<String>, intents: Intents) -> (Self, Events) {
pub fn new(token: String, intents: Intents) -> (Self, Events) {
Self::builder(token, intents).build()
}

Expand All @@ -455,7 +455,7 @@ impl Shard {
/// Create a builder to configure and construct a shard.
///
/// Refer to the builder for more information.
pub fn builder(token: impl Into<String>, intents: Intents) -> ShardBuilder {
pub fn builder(token: String, intents: Intents) -> ShardBuilder {
ShardBuilder::new(token, intents)
}

Expand Down