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<Message>>>,
pub stream: Arc<Mutex<Option<SplitStream<WebSocketStream<Stream<TcpStream, TlsStream<TcpStream>>>>>>>,
pub heartbeat: Arc<Mutex<Heartbeat>>,
/* private fields */
}
Expand description
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<Message>>>
The channel which is used to send websocket messages.
stream: Arc<Mutex<Option<SplitStream<WebSocketStream<Stream<TcpStream, TlsStream<TcpStream>>>>>>>
The shard’s message stream, which is used to receive messages.
heartbeat: Arc<Mutex<Heartbeat>>
This shard’s current heartbeat.
Implementations§
Source§impl Shard
impl Shard
Sourcepub fn new(
token: String,
info: [usize; 2],
ws_uri: String,
) -> impl Future<Item = Shard, Error = Error>
pub fn new( token: String, info: [usize; 2], ws_uri: String, ) -> impl Future<Item = Shard, Error = Error>
Creates a new Discord Shard, with the provided token.
pub fn fulfill_gateway(&mut self, packet: ReceivePacket) -> Result<ShardAction>
Sourcepub fn autoreconnect(
&mut self,
) -> Box<dyn Future<Item = (), Error = Error> + Send>
pub fn autoreconnect( &mut self, ) -> Box<dyn Future<Item = (), Error = Error> + Send>
Attempts to automatically reconnect the shard to Discord.
Sourcepub fn reconnect(&mut self) -> impl Future<Item = (), Error = Error> + Send
pub fn reconnect(&mut self) -> impl Future<Item = (), Error = Error> + Send
Makes a request to reconnect the shard.
Sourcepub fn resume(&mut self) -> impl Future<Item = (), Error = Error> + Send
pub fn resume(&mut self) -> impl Future<Item = (), Error = Error> + Send
Resumes a shard’s past session.
Sourcepub fn resolve_packet(&self, mess: &WebsocketMessage) -> Result<ReceivePacket>
pub fn resolve_packet(&self, mess: &WebsocketMessage) -> Result<ReceivePacket>
Resolves a Websocket message into a ReceivePacket struct.
Sourcepub fn send_payload<T: SendablePacket>(&self, payload: T) -> Result<()>
pub fn send_payload<T: SendablePacket>(&self, payload: T) -> Result<()>
Sends a payload to the Discord Gateway.
Sourcepub fn change_status(&mut self, status: Status) -> Result<()>
pub fn change_status(&mut self, status: Status) -> Result<()>
Change the status of the current shard.
Sourcepub fn change_activity(&mut self, activity: ClientActivity) -> Result<()>
pub fn change_activity(&mut self, activity: ClientActivity) -> Result<()>
Change the activity of the current shard.
Sourcepub fn change_presence(&mut self, presence: ClientPresence) -> Result<()>
pub fn change_presence(&mut self, presence: ClientPresence) -> Result<()>
Change the presence of the current shard.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Shard
impl !RefUnwindSafe for Shard
impl Send for Shard
impl Sync for Shard
impl Unpin for Shard
impl !UnwindSafe for Shard
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more