aboutsummaryrefslogtreecommitdiff
path: root/src/voice/streamer.rs
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2018-07-04 21:28:22 -0700
committerZeyla Hellyer <[email protected]>2018-07-04 21:32:17 -0700
commit7b9764cf1097b0620d871fabe67b5593f0cd4a4a (patch)
tree5b9f3eac6e9c57ac255c73bd1eea07669838f32d /src/voice/streamer.rs
parentFix dead doc-links and add missing ones. (#347) (diff)
downloadserenity-7b9764cf1097b0620d871fabe67b5593f0cd4a4a.tar.xz
serenity-7b9764cf1097b0620d871fabe67b5593f0cd4a4a.zip
Monomorphize all functions
This commit monomorphizes all functions, turning functions like: ```rust fn foo<T: Into<Bar>>(baz: T) { baz = baz.into(); // function here } ``` Into functions like: ```rust fn foo<T: Into<Bar>>(baz: T) { _foo(baz.into()) } fn _foo(baz: Bar) { // function here } ``` This avoids binary bloat and improves build times, by reducing the amount of code duplication.
Diffstat (limited to 'src/voice/streamer.rs')
-rw-r--r--src/voice/streamer.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/voice/streamer.rs b/src/voice/streamer.rs
index bf77b1d..cd7cae8 100644
--- a/src/voice/streamer.rs
+++ b/src/voice/streamer.rs
@@ -100,8 +100,10 @@ impl<R: Read + Send> AudioSource for InputSource<R> {
/// Opens an audio file through `ffmpeg` and creates an audio source.
pub fn ffmpeg<P: AsRef<OsStr>>(path: P) -> Result<Box<AudioSource>> {
- let path = path.as_ref();
+ _ffmpeg(path.as_ref())
+}
+fn _ffmpeg(path: &OsStr) -> Result<Box<AudioSource>> {
// Will fail if the path is not to a file on the fs. Likely a YouTube URI.
let is_stereo = is_stereo(path).unwrap_or(false);
let stereo_val = if is_stereo { "2" } else { "1" };
@@ -133,7 +135,11 @@ pub fn ffmpeg<P: AsRef<OsStr>>(path: P) -> Result<Box<AudioSource>> {
/// Creates a streamed audio source from a DCA file.
/// Currently only accepts the DCA1 format.
pub fn dca<P: AsRef<OsStr>>(path: P) -> StdResult<Box<AudioSource>, DcaError> {
- let file = File::open(path.as_ref()).map_err(DcaError::IoError)?;
+ _dca(path.as_ref())
+}
+
+fn _dca(path: &OsStr) -> StdResult<Box<AudioSource>, DcaError> {
+ let file = File::open(path).map_err(DcaError::IoError)?;
let mut reader = BufReader::new(file);