Skip to main content

ActivityResponseData

Struct ActivityResponseData 

Source
pub struct ActivityResponseData {
    pub activity: ActivityPayload,
    /* private fields */
}
Expand description

Data received in response from the server after sending a SET_ACTIVITY command.

Note that this struct doesn’t fully cover the schema of the actual response since most of the fields that are found are the same as the actual activity that is sent.

More importantly, open-source implementations of RPC (e.g. arRPC) have different response styles so the actual output of this struct may vary depending on what client you are using.

Fields§

§activity: ActivityPayload

The activity payload which came in response to the send.

Implementations§

Source§

impl ActivityResponseData

Source

pub fn application_id(&self) -> Option<&str>

The ID of the application

Source

pub fn platform(&self) -> Option<&str>

The platform of the host.

Examples found in repository?
examples/indefinite.rs (line 20)
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}
Source

pub fn metadata(&self) -> Option<&Value>

Trait Implementations§

Source§

impl Clone for ActivityResponseData

Source§

fn clone(&self) -> ActivityResponseData

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 ActivityResponseData

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ActivityResponseData

Source§

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§

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.

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,