Admin 7301725791
Some checks failed
Desktop Release / Bootstrap updater signing key (push) Has been cancelled
Desktop Release / Windows x64 NSIS (push) Has been cancelled
Desktop Release / Linux x64 DEB + AppImage (push) Has been cancelled
Desktop Release / Publish public desktop release (push) Has been cancelled
feat: add system printer setup and forwarding selection
2026-09-23 23:59:33 +00:00

125 lines
3.1 KiB
Rust

use serde::{Deserialize, Serialize};
use serde_json::Value;
use uuid::Uuid;
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "kebab-case")]
pub enum CaptureMode {
RawProxy,
SpoolFolder,
Both,
}
impl Default for CaptureMode {
fn default() -> Self {
Self::RawProxy
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AppConfig {
pub mode: CaptureMode,
pub listen_addr: String,
pub forward_addr: String,
#[serde(default)]
pub forward_printer: String,
pub spool_dir: String,
pub api_base_url: String,
pub issuer: String,
pub client_id: String,
pub station_id: String,
pub installation_id: String,
pub device_id: Option<String>,
}
impl Default for AppConfig {
fn default() -> Self {
Self {
mode: CaptureMode::RawProxy,
listen_addr: "127.0.0.1:9100".into(),
forward_addr: String::new(),
forward_printer: String::new(),
spool_dir: String::new(),
api_base_url: "https://fieldlens.arrowstack.dev".into(),
issuer: "https://auth.arrowstack.dev/realms/dev".into(),
client_id: "fieldlens-print".into(),
station_id: String::new(),
installation_id: Uuid::new_v4().to_string(),
device_id: None,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct DecodedBarcode {
pub format: String,
pub value: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct JobSummary {
pub id: String,
pub source: String,
pub label: String,
pub bytes: usize,
pub barcodes: Vec<DecodedBarcode>,
pub captured_at: String,
pub forwarded: bool,
pub error: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ScanEvent {
pub id: String,
pub raw_value: String,
pub format: String,
pub duplicate: bool,
pub captured_at: String,
pub source: String,
pub source_metadata: Value,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CaptureStatus {
pub running: bool,
pub mode: CaptureMode,
pub pending: usize,
pub jobs: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct AuthState {
pub device_code: Option<String>,
pub access_token: Option<String>,
pub refresh_token: Option<String>,
pub expires_at_unix: Option<i64>,
pub poll_interval: u64,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct LoginStart {
pub user_code: String,
pub verification_uri: String,
pub verification_uri_complete: Option<String>,
pub expires_in: u64,
pub interval: u64,
}
#[derive(Debug, Clone, Serialize)]
pub struct LoginPoll {
pub status: String,
}
#[derive(Debug, Clone, Serialize)]
pub struct SyncResult {
pub synced: usize,
pub pending: usize,
}