audiofox 1.0.3

Cross platform audio capture made easy!
Documentation
// SPDX-License-Identifier: GPL-2.0-or-later WITH Classpath-exception-2.0
// Audiofox, the audio capturer!
// Copyright (c) 2026 foxberries

use uuid::Uuid;

use crate::common::callback::AudioCallbackFn;
use crate::common::result::Result;
use crate::common::source::{AudioSource, AudioSources};

/// Common internal name for Audiofox. Audiofox is represented as `audiofox` in all internal usages,
/// and as `Audiofox` in sources of documentation.
pub const AUDIOFOX: &str = "audiofox";

/// Implementation contract for Audiofox. To add a new platform to Audiofox, implement this trait.
///
/// A valid implementation of Audiofox does the following:
/// 1. Includes functionality for `start()`, `list()`, and `link()`.
/// 2. Gracefully cleans up its `LinkHandle` and `AudioManager` on drop. Because `stop()` and `unlink()`
///    are merely drop aliases, these are covered by the library wrapper.
/// 3. Adheres to all other project conventions.
///
/// See `manager.rs` in any implementation in the `platform` crate for further guidance.
pub trait Audiofox: Sized {
    /// A handle to manage the lifetime of a stream.
    type LinkHandle: Drop;
    /// Initialize the audio manager.
    fn start() -> Result<Self>;
    /// Get a list of available audio sources.
    fn list(&self) -> Result<AudioSources>;
    /// Link one or more audio sources to Audiofox. If successful, start streaming audio.
    fn link<F>(&self, uuid: Uuid, sources: &[AudioSource], callback: F) -> Result<Self::LinkHandle>
    where
        F: AudioCallbackFn;
}