133 lines
3.0 KiB
Rust
133 lines
3.0 KiB
Rust
/// Stub implementation of the platform interface, so that we can
|
|
/// `cargo check` without any --feature flags.
|
|
use crate::{
|
|
app::{ConnectTarget, SharedState},
|
|
effects::AudioProcessor,
|
|
};
|
|
use color_eyre::eyre::Error;
|
|
use futures_channel::mpsc::UnboundedReceiver;
|
|
use mumble_web2_common::{ProxyOverrides, ServerStatus};
|
|
use std::future::Future;
|
|
|
|
pub struct StubPlatform;
|
|
|
|
impl super::PlatformInterface for StubPlatform {
|
|
type AudioSystem = StubAudioSystem;
|
|
type ConfigSystem = StubConfigSystem;
|
|
|
|
fn init_logging() {
|
|
panic!("stubbed platform")
|
|
}
|
|
|
|
fn request_permissions() {
|
|
panic!("stubbed platform")
|
|
}
|
|
|
|
fn network_connect(
|
|
_target: ConnectTarget,
|
|
_username: String,
|
|
_event_rx: &mut UnboundedReceiver<crate::app::Command>,
|
|
_overrides: &ProxyOverrides,
|
|
_state: SharedState,
|
|
) -> impl Future<Output = Result<(), Error>> {
|
|
async { panic!("stubbed platform") }
|
|
}
|
|
|
|
fn get_status(
|
|
_client: &reqwest::Client,
|
|
_address: &str,
|
|
) -> impl Future<Output = color_eyre::Result<ServerStatus>> {
|
|
async { panic!("stubbed platform") }
|
|
}
|
|
|
|
fn load_proxy_overrides() -> impl Future<Output = color_eyre::Result<ProxyOverrides>> {
|
|
async { panic!("stubbed platform") }
|
|
}
|
|
|
|
fn sleep(_duration: std::time::Duration) -> impl Future<Output = ()> {
|
|
async { panic!("stubbed platform") }
|
|
}
|
|
}
|
|
|
|
pub struct StubAudioSystem;
|
|
|
|
impl super::AudioSystemInterface for StubAudioSystem {
|
|
type AudioPlayer = StubAudioPlayer;
|
|
|
|
async fn new() -> Result<Self, Error> {
|
|
panic!("stubbed platform")
|
|
}
|
|
|
|
fn set_processor(&self, _processor: AudioProcessor) {
|
|
panic!("stubbed platform")
|
|
}
|
|
|
|
fn start_recording(
|
|
&mut self,
|
|
_each: impl FnMut(Vec<u8>, bool) + Send + 'static,
|
|
) -> Result<(), Error> {
|
|
panic!("stubbed platform")
|
|
}
|
|
|
|
fn create_player(&mut self) -> Result<Self::AudioPlayer, Error> {
|
|
panic!("stubbed platform")
|
|
}
|
|
}
|
|
|
|
pub struct StubAudioPlayer;
|
|
|
|
impl super::AudioPlayerInterface for StubAudioPlayer {
|
|
fn play_opus(&mut self, _payload: &[u8]) {
|
|
panic!("stubbed platform")
|
|
}
|
|
}
|
|
|
|
#[derive(Clone)]
|
|
pub struct StubConfigSystem;
|
|
|
|
impl super::ConfigSystemInterface for StubConfigSystem {
|
|
fn new() -> Result<Self, Error> {
|
|
panic!("stubbed platform")
|
|
}
|
|
|
|
fn config_get<T>(&self, key: &str) -> Option<T>
|
|
where
|
|
T: serde::de::DeserializeOwned,
|
|
{
|
|
panic!("stubbed platform")
|
|
}
|
|
|
|
fn config_set<T>(&self, key: &str, value: &T)
|
|
where
|
|
T: serde::Serialize,
|
|
{
|
|
panic!("stubbed platform")
|
|
}
|
|
}
|
|
|
|
#[allow(unused)]
|
|
pub struct SpawnHandle;
|
|
|
|
impl SpawnHandle {
|
|
#[allow(unused)]
|
|
pub fn spawn<F>(&self, _future: F)
|
|
where
|
|
F: Future<Output = ()> + 'static,
|
|
{
|
|
panic!("stubbed platform")
|
|
}
|
|
|
|
#[allow(unused)]
|
|
pub fn current() -> Self {
|
|
SpawnHandle
|
|
}
|
|
}
|
|
|
|
#[allow(unused)]
|
|
pub fn spawn<F>(_future: F)
|
|
where
|
|
F: Future<Output = ()> + 'static,
|
|
{
|
|
panic!("stubbed platform")
|
|
}
|