pub struct ConfigEnv {Show 13 fields
pub service_name: String,
pub service_vers: String,
pub pispas_host: String,
pub remote_host: String,
pub remote_port: u16,
pub remote_ussl: bool,
pub local_host: String,
pub local_port: u16,
pub local_ussl: bool,
pub modules: Vec<String>,
pub list_printers: Option<Vec<String>>,
pub place_id: Option<i64>,
pub objid: Option<i64>,
}Expand description
Runtime configuration loaded from the install’s .env file.
ConfigEnv is the single struct that every binary reads at startup.
Fields are plain POD (strings, booleans, ports) so the type is trivially
serializable to JSON for the Tauri configurator UI.
§Lifecycle
- The installer writes a default
.envviainit_envon first run. - Each binary calls
ConfigEnv::loadat startup, which reads the.envthroughdotenv::from_pathand materialises the struct. - The configurator calls
ConfigEnv::saveafter the user edits a field, then pushes an IPC restart message topispas-modules.
§Invariants
local_ussl = truerequires the embedded TLS cert and a client that connects viawss://local.unpispas.es:<local_port>. Binding to127.0.0.1is fine because DNS resolveslocal.unpispas.esthere.modulesis an ordered list used bypispas_modules::load_servicesto instantiate the services. Names not in the match arm are logged and ignored.
§Extending
Adding a field requires touching four places — see CLAUDE.md § 5.
Forgetting one of them silently resets the new field to its default
every time the user saves from the configurator.
Fields§
§service_name: StringStable identity of this install. Used as the Windows Service name and echoed back in every WebSocket message envelope.
service_vers: StringBuild version tag, echoed in message envelopes for log correlation.
pispas_host: StringBackend REST API hostname (e.g. api.unpispas.es).
remote_host: StringBackend WebSocket hostname that pispas-modules keeps an outbound
connection to (e.g. wss.unpispas.es).
remote_port: u16Backend WebSocket port. Usually 443.
remote_ussl: booltrue → connect with wss://, false → ws://.
local_host: StringBind address for the local WebSocket server. Almost always
127.0.0.1. See docs/CONFIGURATION.md before changing.
local_port: u16Bind port for the local WebSocket server. Default 5005.
local_ussl: booltrue → accept TLS on the local socket (recommended for browser
clients that require wss://). The listener is dual-mode and still
accepts plain ws:// when this is on.
modules: Vec<String>Ordered list of service modules to load at boot
(base, print, paytef, …).
list_printers: Option<Vec<String>>Cached printer list shown in the configurator UI. Refreshed by the service on demand.
place_id: Option<i64>Place this TPV belongs to. None until the first authenticated
client opens the local WS and sends a CHECK with place_id
(first-write-wins). Once set, mismatching place_id on a future
CHECK is rejected — the operator must explicitly reset identity
from the configurator to re-pair the TPV to a different place.
objid: Option<i64>Backend-assigned technical id (PK of the RASPPI table). None
until the WSR CONNECT response delivers it. Used for routing
(the WSR indexes by objid, not by service_name) and as the
FQDN prefix of the per-TPV LE cert (<objid>.local.unpispas.es).
Implementations§
Source§impl ConfigEnv
impl ConfigEnv
pub fn load() -> Self
Sourcepub fn set_place_id(&mut self, new_place_id: i64) -> Result<(), String>
pub fn set_place_id(&mut self, new_place_id: i64) -> Result<(), String>
Set place_id and persist to .env. First-write-wins: returns
Err if place_id is already set to a different value (the
operator must explicitly reset identity to re-pair the TPV).
Setting the same value is a no-op (idempotent).
Sourcepub fn set_objid(&mut self, new_objid: i64)
pub fn set_objid(&mut self, new_objid: i64)
Set objid and persist. objid is assigned by the backend in
the WSR CONNECT response. Once we have it, it should never
change for the lifetime of the install — but we don’t enforce
that here; the backend is the source of truth.
Sourcepub fn forget_identity(&mut self)
pub fn forget_identity(&mut self)
Drop the bootstrap fields and let the TPV re-pair from scratch.
Triggered by the configurator UI when an operator wants to move
the TPV to a different place. The backend should also be told
to delete the old RASPPI row separately.
pub fn change_service_name(&mut self, new_name: &str)
pub fn change_service_vers(&mut self, new_vers: &str)
pub fn change_pispas_host(&mut self, new_host: &str)
pub fn change_remote_host(&mut self, new_host: &str)
pub fn change_remote_port(&mut self, new_port: u16)
pub fn change_remote_ussl(&mut self, ussl: bool)
pub fn change_local_host(&mut self, new_host: &str)
pub fn change_local_port(&mut self, new_port: u16)
pub fn change_local_ussl(&mut self, ussl: bool)
pub fn change_modules(&mut self, new_modules: Vec<String>)
pub fn save(&self)
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ConfigEnv
impl<'de> Deserialize<'de> for ConfigEnv
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl StructuralPartialEq for ConfigEnv
Auto Trait Implementations§
impl Freeze for ConfigEnv
impl RefUnwindSafe for ConfigEnv
impl Send for ConfigEnv
impl Sync for ConfigEnv
impl Unpin for ConfigEnv
impl UnwindSafe for ConfigEnv
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more