diff options
author | Guillaume Desmottes <guillaume.desmottes@onestream.live> | 2021-12-22 14:49:30 +0300 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@onestream.live> | 2021-12-22 14:53:11 +0300 |
commit | 4a5815cc9780dc2fbe44212c73d5ff6d75d1ff6b (patch) | |
tree | dd4b9211be598776376cec787ddeb49b147e2a1d /utils | |
parent | 7c909e59a96ac18556308469cb5988f5fb8eaaf7 (diff) |
uriplaylistbin: factor out create_items()
Diffstat (limited to 'utils')
-rw-r--r-- | utils/uriplaylistbin/src/uriplaylistbin/imp.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/utils/uriplaylistbin/src/uriplaylistbin/imp.rs b/utils/uriplaylistbin/src/uriplaylistbin/imp.rs index bca28653..979be020 100644 --- a/utils/uriplaylistbin/src/uriplaylistbin/imp.rs +++ b/utils/uriplaylistbin/src/uriplaylistbin/imp.rs @@ -617,6 +617,15 @@ struct Playlist { impl Playlist { fn new(uris: Vec<String>, iterations: u32) -> Self { + Self { + items: Self::create_items(uris, iterations), + } + } + + fn create_items( + uris: Vec<String>, + iterations: u32, + ) -> Box<dyn Iterator<Item = Item> + Send + Sync> { fn infinite_iter(uris: Vec<String>) -> Box<dyn Iterator<Item = Item> + Send + Sync> { Box::new( uris.into_iter() @@ -642,13 +651,11 @@ impl Playlist { ) } - let items = if iterations == 0 { + if iterations == 0 { infinite_iter(uris) } else { finite_iter(uris, iterations) - }; - - Self { items } + } } fn next(&mut self) -> Result<Option<Item>, PlaylistError> { |