// License: see LICENSE file at root directory of `master` branch

//! # Server
//!
//! A client connecting to Namaste server is expected to send:
//!
//! - A command.
//! - Data belonged to the command.
//!
//! Currently, supported commands are: [`CMD_BOOK`][::CMD_BOOK], [`CMD_CHECK_OUT`][::CMD_CHECK_OUT].
//!
//! Server is expected to send back one-byte result. A zero (`0`) means `false`, others mean `true`.
//!
//! [::CMD_BOOK]: constant.CMD_BOOK.html
//! [::CMD_CHECK_OUT]: constant.CMD_CHECK_OUT.html

/// # Default port
pub const DEFAULT_PORT: u16 = 64009;

/// # Command to book a seat
///
/// ## Data
///
/// - UID - _must_ be a constant.
/// - Handshake UID - _should_ be generated per each command.
/// - Client's local TCP server port, consisting of 2 bytes, in big-endian order.
pub const CMD_BOOK: u8 = 0;

/// # Command to check out
///
/// ## Data
///
/// - UID - the one previously sent via [`CMD_BOOK`][::CMD_BOOK].
/// - Handshake UID - the one previously sent via [`CMD_BOOK`][::CMD_BOOK].
///
/// [::CMD_BOOK]: constant.CMD_BOOK.html
pub const CMD_CHECK_OUT: u8 = 1;

#[test]
fn tests() {
    use std::collections::HashSet;

    const CMDS: &[u8] = &[CMD_BOOK, CMD_CHECK_OUT];

    let cmd_set: HashSet<_> = CMDS.iter().collect();
    assert_eq!(CMDS.len(), cmd_set.len());
}
