crates/veilvoice-setup/src/lib.rs
veilvoice-setup · 171 lines · read the source here · or on GitHub
Everything that puts VeilVoice on a machine, and everything that reports what is already on it. Two modules: install does the per-user install and its exact reversal, companions finds the optional third-party software that live mode is easier with and says who makes each piece.
Why this is a library and not part of the command line
It was part of the command line. install.rs lived inside the veilvoice-cli binary crate, which meant the desktop application could not call a single line of it, because a binary crate has no consumers. The choice was to reimplement the installer behind the graphical front end, or to move the logic somewhere both front ends can reach. Reimplementing it would have produced two programs that edit PATH, drifting apart at whatever rate nobody noticed, and the PATH edit is the one operation here that can damage a machine.
So this crate is the installer, and both front ends are front ends. The command line calls install::install; so does the desktop app's setup tab. There is one implementation of the careful part, and one set of tests covering it.
What it will not do
It never runs somebody else's installer. companions reports what is present and prepares an exact command for what is not, and where that command is "open the vendor's download page" it says so rather than fetching and executing an unverified binary. A project whose entire subject is verifying what you run has no business being casual about that.
It never asks for administrator rights. Everything install does is inside the user's own account. Where a companion genuinely needs privilege, such as a system package manager or an audio driver, that fact is reported and the command is handed over rather than run, because a graphical program cannot honestly collect a sudo password and this one does not try.
Nothing is ticked by default. There are no checkboxes at all: each companion is a separate, deliberate action. The rule that predates this crate, which is to detect, say what it is and who makes it, and act only on an explicit yes, is unchanged by the interface getting prettier.
No unsafe, and therefore some subprocesses
#![forbid(unsafe_code)] holds here as everywhere else in the workspace, so the Windows registry is reached through reg.exe rather than the Win32 API. command wraps every spawn so that none of them flashes a console window when the desktop application is the caller, which is the defect that shipped in v0.1.10, and a test reads this crate's own source to catch a spawn that forgets.
In plain words
This installs the program, if you want it installed.
You do not have to. Unzipping it and running it is a perfectly normal way to use it, and this says so rather than treating it as a mistake. Installing does three small things -- copies the program into your own folder, adds it to your PATH so typing its name works, and adds an entry so Windows can remove it -- and nothing else. No administrator rights, no service.
It also looks for the few other programs VeilVoice can work alongside, tells you who makes each one, and installs none of them unless you say so.
WHAT THIS FILE CONTAINS
171 lines defining 3 functions (0 public), 0 types and 1 constant. Everything below is read out of the source, so it cannot disagree with the code.
WHAT CALLS WHAT
The functions this file defines, and the calls between them. An edge means the callee's name appears, called, inside the caller's body. This is a syntactic reading, not a type-resolved one.
The same graph as Mermaid source
%%{init: {"theme":"base","themeVariables":{"background":"#1a1b26","primaryColor":"#1f2335","primaryTextColor":"#c0caf5","primaryBorderColor":"#7aa2f7","secondaryColor":"#16161e","tertiaryColor":"#16161e","lineColor":"#737aa2","textColor":"#c0caf5","mainBkg":"#1f2335","nodeBorder":"#7aa2f7","clusterBkg":"#16161e","clusterBorder":"#2f3549","fontFamily":"ui-monospace, SFMono-Regular, Consolas, monospace","fontSize":"14px"}}}%%
flowchart TD
n_command["command<br/>line 90"]
n_hide_console["hide_console<br/>line 104"]
n_hide_console["hide_console<br/>line 114"]
n_command --> n_hide_console
click n_command href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-setup/src/lib.rs#L90" "open the source"
click n_hide_console href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-setup/src/lib.rs#L104" "open the source"
click n_hide_console href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-setup/src/lib.rs#L114" "open the source"
classDef helper fill:#1f2335,stroke:#bb9af7,color:#c0caf5
class n_command,n_hide_console,n_hide_console helper
This site loads no third-party script, so it cannot run Mermaid; the diagram above is the same nodes and edges drawn by the generator instead. GitHub renders the source below directly.
ITEMS
| Item | Line | Documentation |
|---|---|---|
VERSION pub const | 78 | Crate version string, surfaced in the About panel. |
command pub(crate) fn | 90 | Spawn without a console window. |
hide_console fn | 104 | The Windows half of command. |
hide_console fn | 114 | The everywhere-else half of command: nothing to hide, and no console is created by spawning a process in the first place. |