Skip to main content

Config

Struct Config 

Source
pub struct Config { /* private fields */ }
Expand description

The configuration of a Shard.

Cheap to clone. Clones share the TLS configuration and the IDENTIFY queue, so shards created from clones of one configuration take turns identifying. Build one with Config::builder.

The Debug implementation redacts the token.

discord.js counterpart: WebSocketManagerOptions (@discordjs/ws).

Implementations§

Source§

impl Config

Source

pub fn new(token: impl Into<String>, intents: Intents) -> Self

Creates a configuration with default settings.

Pass the raw token, without the Bot prefix.

discord.js counterpart: new WebSocketManager(options) (@discordjs/ws).

Source

pub fn builder(token: impl Into<String>, intents: Intents) -> ConfigBuilder

Returns a builder to customise the configuration.

discord.js counterpart: WebSocketManagerOptions (@discordjs/ws).

§Examples
use djs_gateway::{Compression, Config};
use djs_model::gateway::Intents;

let config = Config::builder("my-token", Intents::GUILDS | Intents::GUILD_MESSAGES)
    .gateway_url("wss://gateway.discord.gg")
    .compression(Compression::None)
    .large_threshold(250)
    .build();
assert_eq!(config.intents(), Intents::GUILDS | Intents::GUILD_MESSAGES);
Source

pub const fn intents(&self) -> Intents

Returns the gateway intents.

discord.js counterpart: the intents option of WebSocketManagerOptions (@discordjs/ws).

Source

pub fn gateway_url(&self) -> &str

Returns the gateway URL used for new sessions.

discord.js counterpart: none (@discordjs/ws uses the URL of Get Gateway Bot).

Source

pub const fn compression(&self) -> Compression

Returns the transport compression.

discord.js counterpart: the compression option of WebSocketManagerOptions (@discordjs/ws).

Source

pub const fn presence(&self) -> Option<&UpdatePresence>

Returns the presence shards using this configuration start with.

discord.js counterpart: the initialPresence option of WebSocketManagerOptions (@discordjs/ws).

Source

pub fn identify_queue(&self) -> &Arc<dyn IdentifyQueue> ⓘ

Returns the queue shards using this configuration wait in before identifying.

discord.js counterpart: the buildIdentifyThrottler option of WebSocketManagerOptions (@discordjs/ws).

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more