expose public api, enable rust library output

This commit is contained in:
ppc
2026-01-09 20:30:18 +00:00
parent 59d1a8bd3e
commit 3cae734dbd
5 changed files with 17 additions and 10 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ description.workspace = true
[lib]
name = "amnet"
crate-type = ["cdylib"]
crate-type = ["cdylib", "rlib"]
[profile.release]
lto = true
+2 -2
View File
@@ -24,7 +24,7 @@ mod limits {
static CONFIG: OnceLock<Config> = OnceLock::new();
pub (crate) struct Config {
pub struct Config {
/// Game ID (4 characters or none)
pub game_id: Option<String>,
@@ -58,7 +58,7 @@ impl Config {
fn load() -> Result<Self, Box<dyn std::error::Error>> {
let config_path = env::var(defaults::CONFIG_FILE_ENV).unwrap_or_else(|_| defaults::CONFIG_FILE.to_string());
let ini = Ini::load_from_file(&config_path).map_err(|e| format!("Failed to load config file '{}': {}", config_path, e))?;
let ini = Ini::load_from_file(&config_path)?;
let io_section = ini.section(Some("aimeio")).ok_or("Missing [aimeio] section")?;
let aime_section = ini.section(Some("aime"));
+11 -4
View File
@@ -4,10 +4,6 @@ use tokio::net::TcpListener;
use tokio::runtime::Runtime;
use tracing::{debug, info, warn};
use crate::card::CardPresenter;
use crate::config::Config;
use crate::metrics::SystemMetrics;
mod config;
mod card;
mod webapi;
@@ -15,6 +11,17 @@ mod metrics;
mod utils;
mod webserver;
use card::CardPresenter;
use config::Config;
use metrics::SystemMetrics;
// Re-export public API for library users
pub use config::Config as ServerConfig;
pub use card::{CardPresenter as CardSlot, StoredCard, CardPresentResult};
pub use metrics::SystemMetrics as Metrics;
pub use webserver::build_server;
pub use utils::{format_hex_bytes, parse_access_code, parse_idm_hex};
static WEBSERVER_INIT: OnceLock<()> = OnceLock::<()>::new();
#[unsafe(no_mangle)]
+1 -1
View File
@@ -3,7 +3,7 @@ use std::{sync::{Mutex, OnceLock}, time::{Duration, Instant}};
static METRICS: OnceLock<SystemMetrics> = OnceLock::new();
#[derive(Debug)]
pub (crate) struct SystemMetrics {
pub struct SystemMetrics {
start_time: OnceLock<Instant>,
last_poll_time: Mutex<Option<Instant>>,
}
+2 -2
View File
@@ -5,7 +5,7 @@ pub fn format_hex_bytes(bytes: &[u8]) -> String {
.join(" ")
}
pub (crate) fn parse_access_code(code: &String) -> Option<[u8; 10]> {
pub fn parse_access_code(code: &String) -> Option<[u8; 10]> {
let matrix_code = code.replace(" ", "");
if code.chars().any(|c| !c.is_ascii_hexdigit() && !c.is_whitespace()) && matrix_code.len() != 20 {
@@ -24,7 +24,7 @@ pub (crate) fn parse_access_code(code: &String) -> Option<[u8; 10]> {
Some(bytes)
}
pub (crate) fn parse_idm_hex(idm_hex: &String) -> Option<[u8; 8]> {
pub fn parse_idm_hex(idm_hex: &String) -> Option<[u8; 8]> {
if idm_hex.len() != 16 || idm_hex.chars().any(|c| !c.is_ascii_hexdigit()) {
return None;
}