//! Daemon ↔ greeter message types.
//!
//! Flow:
//! 1. Greeter sends `Request::BeginAuth { username }`.
//! 2. Daemon may emit zero or more `Response::AuthChallenge { prompt, secret }`
//!    while running the PAM conversation. For each challenge the greeter
//!    replies with `Request::AuthResponse { answer }`.
//! 3. On success the daemon sends `Response::AuthAccepted` and starts spawning
//!    the user session on a fresh VT.
//! 4. On failure the daemon sends `Response::AuthRejected { reason }`. The
//!    greeter may issue another `Request::BeginAuth` to retry.
//! 5. When the spawned session signals "first frame painted" (out-of-band
//!    via a separate socket the daemon owns), the daemon issues
//!    `Response::SessionReady { vt }`. The greeter then exits cleanly so
//!    the daemon can issue `VT_ACTIVATE` to the new VT.
//! 6. Either side may abort the in-progress flow with `Request::Cancel`.
//!    Fatal protocol or system errors come through `Response::Error`.

use serde::{ Deserialize, Serialize };

#[ derive( Debug, Clone, Serialize, Deserialize ) ]
#[ serde( tag = "type" ) ]
pub enum Request
{
	BeginAuth    { username: String },
	AuthResponse { answer: Option<String> },
	Cancel,
	PowerOff,
	Reboot,
}

#[ derive( Debug, Clone, Serialize, Deserialize ) ]
#[ serde( tag = "type" ) ]
pub enum Response
{
	AuthChallenge { prompt: String, secret: bool },
	AuthAccepted,
	AuthRejected  { reason: String },
	SessionReady  { vt: u32 },
	Error         { description: String },
}
