[][src]Struct twilight_gateway::cluster::config::ClusterConfigBuilder

pub struct ClusterConfigBuilder(_, _);

Builder to create a ClusterConfig.

Implementations

impl ClusterConfigBuilder[src]

pub fn new(token: impl Into<String>) -> Self[src]

Creates a new builder with default configuration values.

Refer to each method to learn their default values.

pub fn build(self) -> ClusterConfig[src]

Consumes the builder and returns the final configuration.

pub fn http_client(self, http_client: Client) -> Self[src]

Sets the twilight_http Client used by the cluster and the shards it manages.

This is needed so that the cluster and shards can retrieve gateway information.

By default, the default client is used.

pub fn large_threshold(self, large_threshold: u64) -> Result<Self>[src]

Sets the "large threshold" of shards.

Refer to the shard's ShardConfigBuilder::large_threshold for more information.

Errors

Returns ShardError::LargeThresholdInvalid if the value was not in the accepted range.

pub fn presence(self, presence: UpdateStatusInfo) -> Self[src]

Sets the presence to use when identifying with the gateway.

Refer to the shard's ShardConfigBuilder::presence for more information.

pub fn intents(self, intents: Option<GatewayIntents>) -> Self[src]

Sets the intents to use when identifying with the gateway.

Refer to the shard's ShardConfigBuilder::intents for more information.

pub fn shard_scheme(self, scheme: ShardScheme) -> Self[src]

Sets the scheme to use for shard managing.

For example, ShardScheme::Auto means that the cluster will automatically manage all of the shards that Discord recommends you use. ShardScheme::Range means that it will manage a range of shards, but not necessarily all of the shards that your bot uses.

The default value is ShardScheme::Auto. For most setups this is an acceptable default.

Examples

Configure a cluster to manage shards 0-9 out of 20 shards total:

use twilight_gateway::cluster::config::{ClusterConfig, ShardScheme};
use std::{
    convert::TryFrom,
    env,
};

let mut config = ClusterConfig::builder(env::var("DISCORD_TOKEN")?);

let scheme = ShardScheme::try_from((0..=9, 20))?;
config.shard_scheme(scheme);

pub fn queue(self, queue: Arc<Box<dyn Queue>>) -> Self[src]

Sets the queue to use for queueing shard connections.

This can be used when having advanced setups with multiple binaries connecting at the same time.

pub fn resume_sessions(
    self,
    resume_sessions: HashMap<u64, ResumeSession>
) -> Self
[src]

Sets the session information to resume shards with

This requires having recovered the resume data when shutting down the cluster NOTE: this does not guarantee these shards will be able to resume. If their sessions are invalid they will have to re-identify as normal

Trait Implementations

impl Debug for ClusterConfigBuilder[src]

impl From<ClusterConfigBuilder> for ClusterConfig[src]

impl<T: Into<String>> From<T> for ClusterConfigBuilder[src]

Auto Trait Implementations

impl !RefUnwindSafe for ClusterConfigBuilder

impl Send for ClusterConfigBuilder

impl Sync for ClusterConfigBuilder

impl Unpin for ClusterConfigBuilder

impl !UnwindSafe for ClusterConfigBuilder

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,