ytmapi_rs/query/
continuations.rs1use super::{PostMethod, PostQuery, Query};
2use crate::{
3 auth::AuthToken,
4 common::{ContinuationParams, YoutubeID},
5 continuations::Continuable,
6 parse::ParseFrom,
7};
8use std::{borrow::Cow, vec::Vec};
9
10pub struct GetContinuationsQuery<'a, Q> {
13 query: &'a Q,
14 continuation_params: ContinuationParams<'static>,
15}
16
17impl<'a, Q> GetContinuationsQuery<'a, Q> {
18 pub fn new<T: Continuable<Q>>(
19 res: &'_ mut T,
20 query: &'a Q,
21 ) -> Option<GetContinuationsQuery<'a, Q>> {
22 let continuation_params = res.take_continuation_params()?;
23 Some(GetContinuationsQuery {
24 continuation_params,
25 query,
26 })
27 }
28 pub fn new_mock_unchecked(query: &'a Q) -> GetContinuationsQuery<'a, Q> {
31 GetContinuationsQuery {
32 query,
33 continuation_params: ContinuationParams::from_raw(""),
34 }
35 }
36}
37
38impl<Q: Query<A>, A: AuthToken> Query<A> for GetContinuationsQuery<'_, Q>
39where
40 Q: PostQuery,
41 Q::Output: ParseFrom<Self>,
42{
43 type Output = Q::Output;
44 type Method = PostMethod;
45}
46
47impl<Q> PostQuery for GetContinuationsQuery<'_, Q>
48where
49 Q: PostQuery,
50{
51 fn header(&self) -> serde_json::Map<String, serde_json::Value> {
52 self.query.header()
53 }
54 fn params(&self) -> Vec<(&str, Cow<str>)> {
55 let params = self.continuation_params.get_raw();
56 vec![("ctoken", params.into()), ("continuation", params.into())]
57 }
58 fn path(&self) -> &str {
59 self.query.path()
60 }
61}