Grcov report - lib.rs
top_levelsrclib.rs
Lines
0 %
Functions
0 %
Branches
100 %
1
// This file is part of hnefatafl-copenhagen.
2
//
3
// hnefatafl-copenhagen is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU Affero General Public License as published by
5
// the Free Software Foundation, either version 3 of the License, or
6
// (at your option) any later version.
7
//
8
// hnefatafl-copenhagen is distributed in the hope that it will be useful,
9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
// GNU Affero General Public License for more details.
12
//
13
// You should have received a copy of the GNU Affero General Public License
14
// along with this program. If not, see <https://www.gnu.org/licenses/>.
15
16
//! An AI, client, engine, and server for the game of Copenhagen Hnefatafl.
17
//!
18
//! ## Feature Flags
19
//!
20
//! By default the `client` and `server` feature flags are enabled.
21
//!
22
//! * client - enable the `hnefatafl-client` binary
23
//! * console - on Windows print output to the console
24
//! * debug - enable iced debug mode, also log on the debug level
25
//! * js - enable options for generating javascript code
26
//! * runic - enable the `icelandic-runic` binary for translating Icelandic to Icelandic Runic
27
//! * server - enable the `hnefatafl-server-full` binary
28
//!
29
//! ## Message Protocol
30
//!
31
//! Get more information about the [message protocol] used by the engine.
32
//!
33
//! [message protocol]: https://docs.rs/hnefatafl-copenhagen/latest/hnefatafl_copenhagen/message/enum.Message.html
34
35
#![deny(clippy::panic)]
36
#![deny(clippy::expect_used)]
37
#![deny(clippy::unwrap_used)]
38
39
use std::{
40
io::{BufRead, BufReader, Write},
41
net::TcpStream,
42
};
43
44
rust_i18n::i18n!();
45
46
pub mod ai;
47
pub mod board;
48
pub mod characters;
49
pub mod draw;
50
pub mod email;
51
pub mod game;
52
pub mod game_tree;
53
pub mod glicko;
54
pub mod heat_map;
55
pub mod locale;
56
pub mod message;
57
pub mod play;
58
pub mod rating;
59
pub mod role;
60
pub mod server_game;
61
pub mod space;
62
pub mod status;
63
mod tests;
64
pub mod time;
65
pub mod tournament;
66
pub mod tree;
67
pub mod utils;
68
69
pub type Id = u128;
70
pub const HOME: &str = "hnefatafl-copenhagen";
71
pub const SERVER_PORT: &str = ":49152";
72
pub const SOCKET_PATH: &str = "/tmp/hnefatafl.sock";
73
pub const VERSION_ID: &str = "ad746a65";
74
75
pub const COPYRIGHT: &str = r".SH COPYRIGHT
76
Copyright (C) 2025-2026 Developers of the hnefatafl-copenhagen project
77
78
This program is free software: you can redistribute it and/or modify
79
it under the terms of the GNU Affero General Public License as published by
80
the Free Software Foundation, either version 3 of the License, or
81
(at your option) any later version.
82
83
This program is distributed in the hope that it will be useful,
84
but WITHOUT ANY WARRANTY; without even the implied warranty of
85
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
86
GNU Affero General Public License for more details.
87
88
You should have received a copy of the GNU Affero General Public License
89
along with this program. If not, see <https://www.gnu.org/licenses/>.
90
";
91
92
pub const LONG_VERSION: &str = concat!(
93
env!("CARGO_PKG_VERSION"),
94
"
95
Copyright (c) 2025-2026 Developers of the hnefatafl-copenhagen project
96
Licensed under the AGPLv3"
97
);
98
99
/// # Errors
100
///
101
/// If read fails.
102
pub fn read_response(reader: &mut BufReader<TcpStream>) -> anyhow::Result<String> {
103
let mut reply = String::new();
104
reader.read_line(&mut reply)?;
105
print!("<- {reply}");
106
Ok(reply)
107
}
108
109
/// # Errors
110
///
111
/// If write fails.
112
pub fn write_command(command: &str, stream: &mut TcpStream) -> anyhow::Result<()> {
113
print!("-> {command}");
114
stream.write_all(command.as_bytes())?;
115
Ok(())
116
}
Date: 2026-01-28 15:49