Skip to content

Commit

Permalink
refactor: rename rpc to activity
Browse files Browse the repository at this point in the history
  • Loading branch information
vyfor committed Dec 6, 2024
1 parent e01274e commit 09ed1af
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 30 deletions.
2 changes: 2 additions & 0 deletions src/activity/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod presence;
pub mod types;
42 changes: 42 additions & 0 deletions src/activity/types.rs
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 })
}
}
22 changes: 0 additions & 22 deletions src/rpc/activity.rs

This file was deleted.

2 changes: 0 additions & 2 deletions src/rpc/mod.rs

This file was deleted.

6 changes: 0 additions & 6 deletions src/rpc/packet.rs

This file was deleted.

0 comments on commit 09ed1af

Please sign in to comment.