pub struct DiscordIPC { /* private fields */ }Expand description
Basic Discord rich presence IPC implementation. See the docs: https://docs.rs/crate/filthy-rich/latest
Implementations§
Source§impl DiscordIPC
impl DiscordIPC
Sourcepub async fn new_from(client_id: &str) -> Result<Self>
pub async fn new_from(client_id: &str) -> Result<Self>
Given a client ID, create a new DiscordIPC instance. Needs to have Discord running for successful execution.
Examples found in repository?
More examples
examples/timed.rs (line 9)
8async fn main() -> Result<()> {
9 let mut client = DiscordIPC::new_from("1463450870480900160").await?;
10
11 client.run().await?;
12
13 client.set_activity("this runs", "for ten seconds").await?;
14 sleep(Duration::from_secs(5)).await;
15 client.set_activity("believe it", "or not").await?;
16 sleep(Duration::from_secs(5)).await;
17
18 Ok(())
19}Sourcepub async fn handshake(&mut self) -> Result<()>
pub async fn handshake(&mut self) -> Result<()>
Bare-bones implementation of handshake with the Discord IPC.
Use .run() instead.
Sourcepub async fn wait_for_ready(&mut self) -> Result<()>
pub async fn wait_for_ready(&mut self) -> Result<()>
Look out for READY in socket frames. Use .run() instead.
Sourcepub async fn run(&mut self) -> Result<()>
pub async fn run(&mut self) -> Result<()>
Convenience function for performing handshake, waiting for READY opcode and handling the IPC response loop.
Examples found in repository?
More examples
examples/timed.rs (line 11)
8async fn main() -> Result<()> {
9 let mut client = DiscordIPC::new_from("1463450870480900160").await?;
10
11 client.run().await?;
12
13 client.set_activity("this runs", "for ten seconds").await?;
14 sleep(Duration::from_secs(5)).await;
15 client.set_activity("believe it", "or not").await?;
16 sleep(Duration::from_secs(5)).await;
17
18 Ok(())
19}Sourcepub async fn wait(&mut self) -> Result<()>
pub async fn wait(&mut self) -> Result<()>
Waits for response from IPC task; can be used to run the client indefinitely.
Sourcepub async fn set_activity(&mut self, top: &str, bottom: &str) -> Result<()>
pub async fn set_activity(&mut self, top: &str, bottom: &str) -> Result<()>
Sets a tiny Discord rich presence activity.
Examples found in repository?
More examples
examples/timed.rs (line 13)
8async fn main() -> Result<()> {
9 let mut client = DiscordIPC::new_from("1463450870480900160").await?;
10
11 client.run().await?;
12
13 client.set_activity("this runs", "for ten seconds").await?;
14 sleep(Duration::from_secs(5)).await;
15 client.set_activity("believe it", "or not").await?;
16 sleep(Duration::from_secs(5)).await;
17
18 Ok(())
19}Auto Trait Implementations§
impl Freeze for DiscordIPC
impl !RefUnwindSafe for DiscordIPC
impl Send for DiscordIPC
impl Sync for DiscordIPC
impl Unpin for DiscordIPC
impl UnsafeUnpin for DiscordIPC
impl !UnwindSafe for DiscordIPC
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
Mutably borrows from an owned value. Read more