lowfi/src/ui/init.rs
Tal 4891e626e1
feat: logging (#127)
* feat: add basic logging for error codes on tracks

* fix: refine log printing to make sure nothing overlaps

* docs: add comments for logger
2026-04-17 20:23:22 +02:00

32 lines
1.0 KiB
Rust

//! Contains the code for initializing the UI and creating a [`ui::Handle`].
use crate::ui::{self, input, interface};
use tokio::sync::broadcast;
impl crate::Tasks {
/// Initializes the UI itself, along with all of the tasks that are related to it.
#[allow(clippy::unused_async)]
pub async fn ui(&mut self, state: ui::State, args: &crate::Args) -> crate::Result<ui::Handle> {
let (utx, urx) = broadcast::channel(8);
#[cfg(feature = "mpris")]
let mpris = ui::mpris::Server::new(state.clone(), self.tx(), urx.resubscribe()).await?;
let params = interface::Params::try_from(args)?;
let interface = interface::Interface::new(params)?;
let logger = interface.logger.clone();
if params.enabled {
self.spawn(ui::run(urx, interface, state));
self.spawn(input::listen(self.tx()));
}
Ok(ui::Handle {
updater: utx,
logger,
#[cfg(feature = "mpris")]
mpris,
})
}
}