crates/veilvoice-cli/src/pipe.rs
veilvoice-cli · 64 lines · read the source here · or on GitHub
A reader who stops reading is not a crash.
println! panics when standard output is a pipe whose reader has gone, which is exactly what veilvoice policy status | head does after ten lines. The program printed a panic message, and a hint about backtraces, under a command that had done what it was asked. A C program would be ended quietly by SIGPIPE, but Rust ignores that signal, and putting it back needs unsafe, which this crate forbids. So the panic is recognised here and answered with a quiet exit, and every other panic is reported as it always was.
WHAT THIS FILE CONTAINS
64 lines defining 2 functions (1 public), 0 types and 1 constant. Everything below is read out of the source, so it cannot disagree with the code.
What happens when it runs. These are the ways in: public, and nothing else in this file calls them, so they are what an outside caller reaches first.
quiet_on_closed_pipeline 19 · Install the hook.
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_quiet_on_closed_pipe(["quiet_on_closed_pipe<br/>line 19"])
n_is_closed_pipe["is_closed_pipe<br/>line 32"]
click n_quiet_on_closed_pipe href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-cli/src/pipe.rs#L19" "open the source"
click n_is_closed_pipe href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-cli/src/pipe.rs#L32" "open the source"
classDef entry fill:#1f2335,stroke:#7aa2f7,color:#c0caf5
class n_quiet_on_closed_pipe entry
classDef helper fill:#1f2335,stroke:#bb9af7,color:#c0caf5
class n_is_closed_pipe helper
subgraph chart_key ["Key"]
direction LR
key_entry["entry: a way in: public, and nothing in this file calls it"]
key_helper["helper: private to this file"]
end
class key_entry entry
class key_helper 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 |
|---|---|---|
CLOSED_PIPE_STATUS const | 16 | The status a shell reports for a program SIGPIPE ended: 128 plus the signal's number. |
quiet_on_closed_pipe pub fn | 19 | Install the hook. |
is_closed_pipe fn | 32 | Whether a panic message is the standard library reporting that a write to standard output failed because nothing reads it any more: EPIPE on every Unix VeilVoice builds for, and ERROR_NO_DATA on Windows. |