[][src]Struct spectacles_gateway::Shard

pub struct Shard {
    pub token: String,
    pub info: [usize; 2],
    pub presence: ClientPresence,
    pub session_id: Option<String>,
    pub interval: Option<u64>,
    pub sender: Arc<Mutex<UnboundedSender<WebsocketMessage>>>,
    pub stream: Arc<Mutex<Option<SplitStream<WebSocketStream<TungsteniteStream<TokioTcpStream, TlsStream<TokioTcpStream>>>>>>>,
    pub heartbeat: Arc<Mutex<Heartbeat>>,
    // some fields omitted
}

A Spectacles Gateway shard.

Fields

token: String

The bot token that this shard will use.

info: [usize; 2]

The shard's info. Includes the shard's ID and the total amount of shards.

presence: ClientPresence

The currently active presence for this shard.

session_id: Option<String>

The session ID of this shard, if applicable.

interval: Option<u64>

The interval at which a heartbeat is made.

sender: Arc<Mutex<UnboundedSender<WebsocketMessage>>>

The channel which is used to send websocket messages.

stream: Arc<Mutex<Option<SplitStream<WebSocketStream<TungsteniteStream<TokioTcpStream, TlsStream<TokioTcpStream>>>>>>>

The shard's message stream, which is used to receive messages.

heartbeat: Arc<Mutex<Heartbeat>>

This shard's current heartbeat.

Methods

impl Shard[src]

pub fn new(
    token: String,
    info: [usize; 2],
    ws_uri: String
) -> impl Future<Item = Shard, Error = Error>
[src]

Creates a new Discord Shard, with the provided token.

pub fn fulfill_gateway(&mut self, packet: ReceivePacket) -> Result<ShardAction>[src]

pub fn identify(&mut self) -> Result<()>[src]

Identifies a shard with Discord.

pub fn autoreconnect(
    &mut self
) -> Box<dyn Future<Item = (), Error = Error> + Send>
[src]

Attempts to automatically reconnect the shard to Discord.

pub fn reconnect(&mut self) -> impl Future<Item = (), Error = Error> + Send[src]

Makes a request to reconnect the shard.

pub fn resume(&mut self) -> impl Future<Item = (), Error = Error> + Send[src]

Resumes a shard's past session.

pub fn resolve_packet(&self, mess: &WebsocketMessage) -> Result<ReceivePacket>[src]

Resolves a Websocket message into a ReceivePacket struct.

pub fn send_payload<T: SendablePacket>(&self, payload: T) -> Result<()>[src]

Sends a payload to the Discord Gateway.

pub fn change_status(&mut self, status: Status) -> Result<()>[src]

Change the status of the current shard.

pub fn change_activity(&mut self, activity: ClientActivity) -> Result<()>[src]

Change the activity of the current shard.

pub fn change_presence(&mut self, presence: ClientPresence) -> Result<()>[src]

Change the presence of the current shard.

Trait Implementations

impl Clone for Shard[src]

default fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl Send for Shard

impl Sync for Shard

Blanket Implementations

impl<T> From for T[src]

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

impl<T, U> TryInto 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<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Erased for T

impl<T> Same for T

type Output = T

Should always be Self

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

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