diff options
Diffstat (limited to 'src/ctx.rs')
-rw-r--r-- | src/ctx.rs | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -1,9 +1,11 @@ use reqwest::StatusCode; use super::deserialize as de; use std::sync::Arc; +use std::collections::BTreeMap; pub mod model { use std::sync::Arc; + use std::collections::BTreeMap; /// The theme representation of a user. #[derive(serde::Serialize, Debug)] @@ -73,14 +75,15 @@ pub mod model { /// Contains text explaining a potential error. Error { error: &'static str }, /// Contains data about a user and what they're listening to. - Data { user: User, scrobble: Scrobble } + Data { user: User, scrobble: Scrobble, query: BTreeMap<String, String> } } } #[derive(Debug)] pub struct ResponseCtx(pub model::Data, pub StatusCode); -impl From<Result<Arc<(de::User, de::Track)>, (StatusCode, &'static str)>> for ResponseCtx { - fn from(v: Result<Arc<(de::User, de::Track)>, (StatusCode, &'static str)>) -> ResponseCtx { +impl From<(Result<Arc<(de::User, de::Track)>, (StatusCode, &'static str)>, BTreeMap<String, String>)> for ResponseCtx { + fn from(v: (Result<Arc<(de::User, de::Track)>, (StatusCode, &'static str)>, BTreeMap<String, String>)) -> ResponseCtx { + let (v, q) = v; match v { Ok(a) => { let (user, track) = a.as_ref(); @@ -111,7 +114,8 @@ impl From<Result<Arc<(de::User, de::Track)>, (StatusCode, &'static str)>> for Re now_playing: track.attr.nowplaying, url: track.url.clone(), loved: track.loved.unwrap_or(false) - } + }, + query: q }, StatusCode::OK) }, Err((status, error)) => { |