//! Call history abstraction.
//!
//! `DbusCallLog` is the provider — a D-Bus client of `calllogs-server`.

use crate::types::HistoryEntry;

pub mod dbus;

pub use dbus::DbusCallLog;

#[ derive( Clone, Debug ) ]
pub enum HistoryError
{
	Backend( String ),
}

pub trait CallLog
{
	fn record( &mut self, entry: HistoryEntry ) -> Result<(), HistoryError>;
	fn recent( &self, limit: usize ) -> Result<Vec<HistoryEntry>, HistoryError>;

	/// Returns `true` once when the log changed since the last call, so the UI
	/// can refresh its cached recents. Polled from the app tick. Static
	/// providers never change, hence the default.
	fn poll_changed( &self ) -> bool
	{
		false
	}
}
