Struct songbird::driver::Driver[][src]

pub struct Driver { /* fields omitted */ }

The control object for a Discord voice connection, handling connection, mixing, encoding, en/decryption, and event generation.

When compiled with the "builtin-queue" feature, each driver includes a track queue as a convenience to prevent the additional overhead of per-guild state management.

Implementations

impl Driver[src]

pub fn new(config: Config) -> Self[src]

Creates a new voice driver.

This will create the core voice tasks in the background.

pub fn connect(&mut self, info: ConnectionInfo) -> Connect

Notable traits for Connect

impl Future for Connect type Output = Result<()>;
[src]

Connects to a voice channel using the specified server.

This method instantly contacts the driver tasks, and its does not need to be awaited to start the actual connection.

pub fn leave(&mut self)[src]

Leaves the current voice channel, disconnecting from it.

This does not forget settings, like whether to be self-deafened or self-muted.

pub fn mute(&mut self, mute: bool)[src]

Sets whether the current connection is to be muted.

If there is no live voice connection, then this only acts as a settings update for future connections.

pub fn is_mute(&self) -> bool[src]

Returns whether the driver is muted (i.e., processes audio internally but submits none).

pub fn play_source(&mut self, source: Input) -> TrackHandle[src]

Plays audio from a source, returning a handle for further control.

This can be a source created via ffmpeg or ytdl.

pub fn play_only_source(&mut self, source: Input) -> TrackHandle[src]

Plays audio from a source, returning a handle for further control.

Unlike play_source, this stops all other sources attached to the channel.

pub fn play(&mut self, track: Track)[src]

Plays audio from a Track object.

This will be one half of the return value of create_player. The main difference between this function and play_source is that this allows for direct manipulation of the Track object before it is passed over to the voice and mixing contexts.

pub fn play_only(&mut self, track: Track)[src]

Exclusively plays audio from a Track object.

This will be one half of the return value of create_player. As in play_only_source, this stops all other sources attached to the channel. Like play, however, this allows for direct manipulation of the Track object before it is passed over to the voice and mixing contexts.

pub fn set_bitrate(&mut self, bitrate: Bitrate)[src]

Sets the bitrate for encoding Opus packets sent along the channel being managed.

The default rate is 128 kbps. Sensible values range between Bits(512) and Bits(512_000) bits per second. Alternatively, Auto and Max remain available.

pub fn stop(&mut self)[src]

Stops playing audio from all sources, if any are set.

pub fn set_config(&mut self, config: Config)[src]

Sets the configuration for this driver.

pub fn add_global_event<F: EventHandler + 'static>(
    &mut self,
    event: Event,
    action: F
)
[src]

Attach a global event handler to an audio context. Global events may receive any EventContext.

Global timing events will tick regardless of whether audio is playing, so long as the bot is connected to a voice channel, and have no tracks. TrackEvents will respond to all relevant tracks, giving some audio elements.

Users must ensure that no costly work or blocking occurs within the supplied function or closure. Taking excess time could prevent timely sending of packets, causing audio glitches and delays.

pub fn remove_all_global_events(&mut self)[src]

Removes all global event handlers from an audio context.

impl Driver[src]

pub fn queue(&self) -> &TrackQueue[src]

Returns a reference to this driver’s built-in queue.

Requires the "builtin-queue" feature. Queue additions should be made via enqueue and enqueue_source.

pub fn enqueue_source(&mut self, source: Input)[src]

Adds an audio Input to this driver’s built-in queue.

Requires the "builtin-queue" feature.

pub fn enqueue(&mut self, track: Track)[src]

Adds an existing Track to this driver’s built-in queue.

Requires the "builtin-queue" feature.

Trait Implementations

impl Clone for Driver[src]

impl Debug for Driver[src]

impl Default for Driver[src]

impl Drop for Driver[src]

fn drop(&mut self)[src]

Leaves the current connected voice channel, if connected to one, and forgets all configurations relevant to this Handler.

Auto Trait Implementations

impl !RefUnwindSafe for Driver

impl Send for Driver

impl Sync for Driver

impl Unpin for Driver

impl !UnwindSafe for Driver

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<T> WithSubscriber for T[src]