1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
use kithara_bufpool::HasPool;
use kithara_events::TrackId;
use super::{Queue, Transition};
use crate::{QueueError, TrackSource};
impl<S> Queue<S>
where
S: HasPool<u8> + HasPool<f32> + Send + Sync + 'static,
{
/// Append a track while this concrete queue remains owned by its caller.
///
/// # Errors
///
/// Returns [`QueueError::Play`] after the resident player is closed.
pub fn append<T: Into<TrackSource<S>>>(&self, source: T) -> Result<TrackId, QueueError> {
self.control.append(source)
}
/// Append a track with a caller-owned stable id.
///
/// # Errors
///
/// Returns [`QueueError::Play`] after the resident player is closed.
pub fn append_with_id<T: Into<TrackSource<S>>>(
&self,
id: TrackId,
source: T,
) -> Result<TrackId, QueueError> {
self.control.append_with_id(id, source)
}
/// Insert a track after `after`, or at the head when it is absent.
///
/// # Errors
///
/// Returns [`QueueError`] when `after` is not present.
pub fn insert<T: Into<TrackSource<S>>>(
&self,
source: T,
after: Option<TrackId>,
) -> Result<TrackId, QueueError> {
self.control.insert(source, after)
}
/// Insert a track with a caller-owned stable id.
///
/// # Errors
///
/// Returns [`QueueError`] when `after` is not present.
pub fn insert_with_id<T: Into<TrackSource<S>>>(
&self,
id: TrackId,
source: T,
after: Option<TrackId>,
) -> Result<TrackId, QueueError> {
self.control.insert_with_id(id, source, after)
}
delegate::delegate! {
to self.control {
/// Advance to the next navigation-owned track.
///
/// # Errors
///
/// Returns a queue or player error when the successor cannot be selected.
pub fn next(&self, transition: Transition) -> Result<Option<TrackId>, QueueError>;
/// Return to the previous navigation-owned track.
///
/// # Errors
///
/// Returns a queue or player error when the predecessor cannot be selected.
pub fn previous(
&self,
transition: Transition,
) -> Result<Option<TrackId>, QueueError>;
}
}
}