-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
44 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod presence; | ||
pub mod types; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use crate::json::parser::Deserializable; | ||
|
||
pub struct Packet { | ||
pub pid: u32, | ||
pub activity: Option<Activity>, | ||
} | ||
|
||
#[derive(Debug, Clone, PartialEq, Eq, Default)] | ||
pub struct Activity { | ||
pub details: Option<String>, | ||
pub state: Option<String>, | ||
pub large_image: Option<String>, | ||
pub large_text: Option<String>, | ||
pub small_image: Option<String>, | ||
pub small_text: Option<String>, | ||
pub buttons: Option<Vec<ActivityButton>>, | ||
pub timestamp: Option<u128>, | ||
} | ||
|
||
#[derive(Debug, Clone, PartialEq, Eq)] | ||
pub struct ActivityButton { | ||
pub label: String, | ||
pub url: String, | ||
} | ||
|
||
impl Deserializable for ActivityButton { | ||
fn deserialize( | ||
input: &std::collections::HashMap<String, crate::json::parser::Value>, | ||
) -> Result<Self, String> { | ||
let label = input | ||
.get("label") | ||
.and_then(|v| v.as_str()) | ||
.ok_or("Missing or invalid 'label' field")? | ||
.to_string(); | ||
let url = input | ||
.get("url") | ||
.and_then(|v| v.as_str()) | ||
.ok_or("Missing or invalid 'url' field")? | ||
.to_string(); | ||
Ok(ActivityButton { label, url }) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.