aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2017-02-11 12:19:57 -0800
committerZeyla Hellyer <[email protected]>2017-02-11 12:19:57 -0800
commit20aa20be545b5d241e502183e808f337379496c4 (patch)
tree1120337fdf7fc6be5668e69d51475177ad176ba8 /src
parentAllow standalone voice connections (diff)
downloadserenity-20aa20be545b5d241e502183e808f337379496c4.tar.xz
serenity-20aa20be545b5d241e502183e808f337379496c4.zip
Small amount of voice docs
Diffstat (limited to 'src')
-rw-r--r--src/ext/voice/error.rs18
-rw-r--r--src/ext/voice/manager.rs6
-rw-r--r--src/ext/voice/mod.rs2
-rw-r--r--src/ext/voice/streamer.rs3
4 files changed, 24 insertions, 5 deletions
diff --git a/src/ext/voice/error.rs b/src/ext/voice/error.rs
index a49229a..55be1f6 100644
--- a/src/ext/voice/error.rs
+++ b/src/ext/voice/error.rs
@@ -1,18 +1,34 @@
use serde_json::Value;
use std::process::Output;
+/// An error returned from the voice module.
+// Errors which are not visible to the end user are hidden.
#[derive(Debug)]
pub enum VoiceError {
- // An indicator that an endpoint URL was invalid.
+ /// An indicator that an endpoint URL was invalid.
EndpointUrl,
+ #[doc(hidden)]
ExpectedHandshake,
+ #[doc(hidden)]
FindingByte,
+ #[doc(hidden)]
HostnameResolve,
+ #[doc(hidden)]
KeyGen,
+ /// An error occurred while checking if a path is stereo.
Streams,
+ #[doc(hidden)]
VoiceModeInvalid,
+ #[doc(hidden)]
VoiceModeUnavailable,
+ /// An error occurred while running `youtube-dl`.
YouTubeDLRun(Output),
+ /// An error occurred while processing the JSON output from `youtube-dl`.
+ ///
+ /// The JSON output is given.
YouTubeDLProcessing(Value),
+ /// The `url` field of the `youtube-dl` JSON output was not present.
+ ///
+ /// The JSON output is given.
YouTubeDLUrl(Value),
}
diff --git a/src/ext/voice/manager.rs b/src/ext/voice/manager.rs
index 4e71195..44530c1 100644
--- a/src/ext/voice/manager.rs
+++ b/src/ext/voice/manager.rs
@@ -37,8 +37,7 @@ impl Manager {
}
/// Retrieves a mutable handler for the given target, if one exists.
- pub fn get<T: Into<Target>>(&mut self, target_id: T)
- -> Option<&mut Handler> {
+ pub fn get<T: Into<Target>>(&mut self, target_id: T) -> Option<&mut Handler> {
self.handlers.get_mut(&target_id.into())
}
@@ -64,8 +63,7 @@ impl Manager {
/// [`Handler`]: struct.Handler.html
/// [`get`]: #method.get
#[allow(map_entry)]
- pub fn join(&mut self, guild_id: Option<GuildId>, channel_id: ChannelId)
- -> &mut Handler {
+ pub fn join(&mut self, guild_id: Option<GuildId>, channel_id: ChannelId) -> &mut Handler {
if let Some(guild_id) = guild_id {
let target = Target::Guild(guild_id);
diff --git a/src/ext/voice/mod.rs b/src/ext/voice/mod.rs
index 38ea3a1..9ccb1d9 100644
--- a/src/ext/voice/mod.rs
+++ b/src/ext/voice/mod.rs
@@ -1,3 +1,5 @@
+//! A module for connecting to voice channels.
+
mod audio;
mod connection;
mod connection_info;
diff --git a/src/ext/voice/streamer.rs b/src/ext/voice/streamer.rs
index 1c08a1b..4d3b9a9 100644
--- a/src/ext/voice/streamer.rs
+++ b/src/ext/voice/streamer.rs
@@ -37,6 +37,7 @@ impl<R: Read + Send> AudioSource for PcmSource<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();
@@ -72,11 +73,13 @@ pub fn ffmpeg<P: AsRef<OsStr>>(path: P) -> Result<Box<AudioSource>> {
Ok(pcm(is_stereo, ChildContainer(command)))
}
+/// Creates a PCM audio source.
pub fn pcm<R: Read + Send + 'static>(is_stereo: bool, reader: R)
-> Box<AudioSource> {
Box::new(PcmSource(is_stereo, reader))
}
+/// Creates a streamed audio source with `youtube-dl` and `ffmpeg`.
pub fn ytdl(uri: &str) -> Result<Box<AudioSource>> {
let args = [
"-f",