basic desktop imp module
This commit is contained in:
+59
-1
@@ -1,6 +1,64 @@
|
||||
use crate::app::Command;
|
||||
use dioxus::hooks::UnboundedReceiver;
|
||||
use std::{fmt, io};
|
||||
|
||||
pub struct Error(anyhow::Error);
|
||||
|
||||
impl From<anyhow::Error> for Error {
|
||||
fn from(value: anyhow::Error) -> Self {
|
||||
Error(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<io::Error> for Error {
|
||||
fn from(value: io::Error) -> Self {
|
||||
Error(value.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl Error {
|
||||
pub fn new(text: String) -> Self {
|
||||
Self(anyhow::Error::msg(text))
|
||||
}
|
||||
|
||||
pub fn log(&self) {
|
||||
eprintln!("{}", self.0);
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for Error {}
|
||||
|
||||
impl fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt::Display::fmt(&self.0, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for Error {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt::Debug::fmt(&self.0, f)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AudioContext();
|
||||
|
||||
pub struct AudioPlayer();
|
||||
|
||||
impl AudioPlayer {
|
||||
pub fn play_opus(&mut self, payload: &[u8]) {
|
||||
dbg!("todo");
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn network_connect(
|
||||
address: String,
|
||||
username: String,
|
||||
event_rx: &mut UnboundedReceiver<Command>,
|
||||
) -> Result<(), JsValue> {
|
||||
) -> Result<(), Error> {
|
||||
dbg!("todo");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn create_player(ctx: &AudioContext) -> Result<AudioPlayer, Error> {
|
||||
Ok(AudioPlayer())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user