//! Domain types for the call log. Mirrors the Android `CallLog.Calls`
//! subset we persist — see `docs/schema.md`.

/// Android `CallLog.Calls.TYPE` values. We persist the type verbatim so the
/// Android Translation Layer can round-trip it; native clients map it to
/// their own direction/outcome model.
pub mod call_type
{
	pub const INCOMING:  i32 = 1;
	pub const OUTGOING:  i32 = 2;
	pub const MISSED:    i32 = 3;
	pub const VOICEMAIL: i32 = 4;
	pub const REJECTED:  i32 = 5;
	pub const BLOCKED:   i32 = 6;
}

/// A stored call-log row.
#[ derive( Debug, Clone ) ]
pub struct Call
{
	pub id: i64,
	pub number: String,
	/// Call start, milliseconds since the Unix epoch.
	pub date: i64,
	/// Talk time in whole seconds (0 for missed/rejected).
	pub duration: i64,
	pub call_type: i32,
	/// Unread flag — set on insert, cleared by `MarkAllRead`.
	pub new: bool,
	/// Name snapshot at insertion time (Android `CACHED_NAME`). `None` when
	/// the caller was unknown.
	pub cached_name: Option<String>,
	pub created_at: i64,
}

/// Fields accepted by `AddCall`.
#[ derive( Debug, Clone ) ]
pub struct NewCall
{
	pub number: String,
	pub date: i64,
	pub duration: i64,
	pub call_type: i32,
	pub cached_name: Option<String>,
}
