//! D-Bus surface for `org.liberux.CallLog1`.
//!
//! Top-level wiring lives here; per-method implementation is in [`service`]
//! and the wire types in [`types`].

use std::sync::Arc;

use crate::db::Database;

pub mod error;
pub mod service;
pub mod types;

pub use service::CallLogService;

pub const SERVICE_NAME: &str = "org.liberux.CallLog1";
pub const OBJECT_PATH:  &str = "/org/liberux/CallLog1";

/// Connect to the session bus, register `CallLogService` at the documented
/// object path, and request the well-known name. Returns the live
/// `Connection` — keep it alive for the lifetime of the daemon.
pub async fn serve( db: Arc<Database> ) -> zbus::Result<zbus::Connection>
{
	let service = CallLogService::new( db );
	zbus::connection::Builder::session()?
		.name( SERVICE_NAME )?
		.serve_at( OBJECT_PATH, service )?
		.build()
		.await
}
