pub fn create_iterator<F, Q>(
numbers: impl ExactSizeIterator<Item = u32>,
total: u32,
config: Config<Q>,
per_shard_config: F,
) -> impl ExactSizeIterator<Item = Shard<Q>>
Expand description
Create a iterator of shards.
Passing a primary config is required. Further customization of this config may be performed in the callback.
§Examples
Start 10 out of 10 shards and count them:
use std::{collections::HashMap, env, sync::Arc};
use twilight_gateway::{Config, Intents};
let token = env::var("DISCORD_TOKEN")?;
let config = Config::new(token.clone(), Intents::GUILDS);
let shards = twilight_gateway::create_iterator(0..10, 10, config, |_, builder| builder.build());
assert_eq!(shards.len(), 10);
§Panics
Panics if range
contains values larger than total
.
Panics if loading TLS certificates fails.