aboutsummaryrefslogtreecommitdiff
path: root/server/src/routes/stream.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/routes/stream.rs')
-rw-r--r--server/src/routes/stream.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/server/src/routes/stream.rs b/server/src/routes/stream.rs
index 469ad07..e7547bd 100644
--- a/server/src/routes/stream.rs
+++ b/server/src/routes/stream.rs
@@ -17,15 +17,15 @@ use rocket::{
};
use std::{
ops::{Deref, Range},
- path::PathBuf,
+ path::{PathBuf, Path},
};
use tokio::io::{duplex, DuplexStream};
use tokio_util::io::SyncIoBridge;
-pub fn stream_uri(path: &PathBuf, tracks: &Vec<u64>, webm: bool) -> String {
+pub fn stream_uri(path: &Path, tracks: &[u64], webm: bool) -> String {
format!(
"/stream/{}?tracks={}&webm={}",
- path.to_str().unwrap().to_string(),
+ path.to_str().unwrap(),
tracks
.iter()
.map(|v| format!("{v}"))
@@ -54,9 +54,8 @@ pub fn r_stream(
.get_item()?;
let remuxer = remuxer.deref().clone();
let tracks = tracks
- .split(",")
+ .split(',')
.map(|e| e.parse().map_err(|_| anyhow!("invalid number")))
- .into_iter()
.collect::<Result<Vec<_>, _>>()?;
let b = SyncIoBridge::new(b);
@@ -119,10 +118,10 @@ impl RequestRange {
Ok(Self(
s.strip_prefix("bytes=")
.ok_or(anyhow!("prefix expected"))?
- .split(",")
+ .split(',')
.map(|s| {
let (l, r) = s
- .split_once("-")
+ .split_once('-')
.ok_or(anyhow!("range delimeter missing"))?;
let km = |s: &str| {
if s.is_empty() {
@@ -133,7 +132,6 @@ impl RequestRange {
};
Ok(km(l)?..km(r)?)
})
- .into_iter()
.collect::<Result<Vec<_>>>()?,
))
}