pub struct ActivityPayload { /* private fields */ }Expand description
Represents an immutable activity which has been sent.
Implementations§
Source§impl ActivityPayload
impl ActivityPayload
Sourcepub fn activity_type(&self) -> Option<ActivityType>
pub fn activity_type(&self) -> Option<ActivityType>
The type of the activity.
Sourcepub fn created_at(&self) -> u64
pub fn created_at(&self) -> u64
When the activity was created.
Examples found in repository?
examples/indefinite.rs (line 21)
8async fn main() -> Result<(), PresenceError> {
9 let mut runner = PresenceRunner::new("1463450870480900160")
10 .on_ready(|data| {
11 println!(
12 "RPC version: v{}; Connected to user: {}",
13 data.version(),
14 data.user.global_name().unwrap_or_default(),
15 )
16 })
17 .on_activity_send(|data| {
18 println!(
19 "Activity sent to app! (running on {})\nCreated at: {}",
20 data.platform().unwrap_or_default(),
21 data.activity.created_at()
22 );
23 })
24 .on_disconnect(|f| println!("Disconnected: {f:?}"))
25 .show_errors() // enables verbose error logging
26 .on_retry(move |c| {
27 if c % 10 == 0 {
28 println!("Retry count {c}; is Discord open?");
29 }
30 });
31
32 let client = runner.run(true).await?;
33
34 // the activity can include any combination of builder function calls
35 let activity = Activity::new()
36 .activity_type(ActivityType::Playing)
37 .details("epic game")
38 .details_url("https://github.com/hitblast")
39 .status_display_type(StatusDisplayType::Details)
40 .large_image("game_icon")
41 .large_text("Playing a game")
42 .large_url("https://hitblast.github.io/")
43 .small_image("status")
44 .small_text("Online")
45 .build()?;
46
47 client.set_activity(activity).await?;
48
49 // indefinitely block here
50 runner.wait().await?;
51
52 Ok(())
53}Sourcepub fn status_display_type(&self) -> Option<StatusDisplayType>
pub fn status_display_type(&self) -> Option<StatusDisplayType>
Which element the activity displays as the status (primary text on members banner).
Sourcepub fn details_url(&self) -> Option<&str>
pub fn details_url(&self) -> Option<&str>
The URL which the details field redirects to when clicked on.
Sourcepub fn state(&self) -> Option<&str>
pub fn state(&self) -> Option<&str>
The state (usually the bottom text but could be on top) for the activity.
Sourcepub fn timestamps(&self) -> &TimestampPayload
pub fn timestamps(&self) -> &TimestampPayload
The timestamp payload object for the activity, containing the start and optionally the end timestamps.
Sourcepub fn assets(&self) -> Option<&AssetsPayload>
pub fn assets(&self) -> Option<&AssetsPayload>
The assets payload object for the activity, containing all the detials of the assets which were optionally sent with the activity.
The buttons for the activity. Each button is represented by a ButtonPayload object instance, and returned as a borrowed
vector of multiple ButtonPayload objects through this function.
Trait Implementations§
Source§impl Clone for ActivityPayload
impl Clone for ActivityPayload
Source§fn clone(&self) -> ActivityPayload
fn clone(&self) -> ActivityPayload
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ActivityPayload
impl Debug for ActivityPayload
Source§impl<'de> Deserialize<'de> for ActivityPayload
impl<'de> Deserialize<'de> for ActivityPayload
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ActivityPayload
impl RefUnwindSafe for ActivityPayload
impl Send for ActivityPayload
impl Sync for ActivityPayload
impl Unpin for ActivityPayload
impl UnsafeUnpin for ActivityPayload
impl UnwindSafe for ActivityPayload
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