Skip to main content

vernier_rs_core/
lib.rs

1//! Algorithms, geometry, and color math for vernier.
2//!
3//! No GUI or platform dependencies live in this crate.
4
5pub mod aspect;
6pub mod color;
7pub mod edge;
8pub mod frame;
9pub mod geometry;
10pub mod handoff;
11pub mod measurement;
12pub mod settings;
13
14pub use aspect::{CommonRatio, Mode as AspectMode, Ratio, classify as classify_aspect};
15pub use color::Rgba;
16pub use edge::{
17    Direction, EdgeBias, EdgeCandidate, EdgeQuad, Tolerance, detect_edges, shrink_to_content,
18    shrink_to_content_frac, shrink_to_content_with_bg, shrink_to_content_with_bg_frac,
19};
20pub use frame::FrameView;
21pub use geometry::{Px, PxRect};
22pub use handoff::{
23    HandoffApp, KNOWN_HANDOFF_APPS, find_installed_apps as find_installed_handoff_apps,
24    lookup_for_binary, render_args, resolve_icon,
25};
26pub use measurement::{
27    Axis, Measurement, Mode as InteractionMode, SnapPoint, axis_biased_snap, best_snap,
28};
29pub use settings::{
30    AppearanceSettings, ClipboardUnit, ColorRgba, CopyFormat, GeneralSettings, IntegrationSettings,
31    RoundingMode, ScreenshotSettings, Settings, ShortcutSettings, ToleranceLevel,
32    ToleranceSettings, settings_path,
33};
34
35/// Stable per-process build identifier — the mtime (in seconds since
36/// the epoch, hex-encoded) of the executable that launched this
37/// process. Captured the first time it's called, so a later rebuild
38/// of the on-disk binary doesn't invalidate the value for an
39/// already-running process. Used by the prefs window's daemon-probe
40/// to detect when the daemon is from an older build than itself.
41pub fn build_id() -> String {
42    use std::sync::OnceLock;
43    use std::time::UNIX_EPOCH;
44    static ID: OnceLock<String> = OnceLock::new();
45    ID.get_or_init(|| {
46        let Ok(exe) = std::env::current_exe() else {
47            return "unknown".to_string();
48        };
49        let Ok(meta) = std::fs::metadata(&exe) else {
50            return "unknown".to_string();
51        };
52        let secs = meta
53            .modified()
54            .ok()
55            .and_then(|t| t.duration_since(UNIX_EPOCH).ok())
56            .map(|d| d.as_secs())
57            .unwrap_or(0);
58        format!("{secs:x}")
59    })
60    .clone()
61}