Module secret_prompt
Expand description
The one password prompt: every secret Tilo asks for — a Wi-Fi passphrase, a polkit password, a VPN login, an unlock, a SIM PIN — is asked by this component, drawn the same by the shell and by apps.
It shows an icon and a title naming who asks and why (“Connect to TruffleBoys2026”), the
resource line, the fields the kind asks for (each a secret TextInput with its own show/hide
button), one notice line under them (an inline error after a wrong secret, Caps Lock, the PIN
length or the attempts a SIM has left), a numeric keypad for the PIN kinds while touch is the
input in use, and Cancel plus a primary button labelled by the action.
Three presentations of the same body: Presentation::Sheet, the modal sheet a painted host
draws itself through the one modal chrome (super::modal_dialog) — Enter answers, Escape
cancels, and it keeps the field clear of an on-screen keyboard
(SecretPrompt::set_keyboard_inset); Presentation::Inline, inside another surface, with
no title or sheet; and Presentation::DialogBody, the body of a retained ModalDialog,
which draws the title and actions (SecretPrompt::into_dialog wires them).
The secret lives only in the fields’ zeroizing buffers and in the SecretAnswer handed out on
submit, which zeroes itself on drop. It is never in the accessibility tree (fields report
protected), a log (the answer’s Debug is redacted), a document or replicated state (fields
are local, with no binding), or a screenshot (a painted secret marks the frame through
crate::secret_paint, so hosts withhold it).
// A painted host:
let mut prompt = SecretPrompt::new(SecretKind::Secret)
.with_icon(Icon::Wifi)
.with_title("Connect to TruffleBoys2026")
.with_resource("WPA2 Personal")
.with_primary_label("Connect");
prompt.set_focus(true);
prompt.place(window, text, theme);
prompt.paint(scene, transform, text, theme);
prompt.handle_event(event, ctx);
match prompt.take_outcome() {
Some(PromptOutcome::Submit(answer)) => connect(answer.secret),
Some(PromptOutcome::Cancel) => close(),
None => {}
}
// …and when the network refuses it:
prompt.reject("Wrong password");Structs§
- Field
Spec - One field a
SecretKind::Fieldsprompt asks for. - Prompt
Layout - Where every part of the prompt landed in its last layout.
- Secret
Answer - What the person typed, handed out once on submit. Every secret is in a
buffer that zeroes itself when dropped;
Debugshows none of them. - Secret
Prompt - The password prompt. See the module documentation.
Enums§
- Field
Role - What one field of a prompt holds.
- Notice
Tone - How the notice line reads.
- Presentation
- How the prompt is framed.
- Prompt
Outcome - How the person answered.
- Secret
Kind - What a prompt asks for.
Constants§
- PUK_
DIGITS - The digits a SIM’s PUK has.
- SIM_
PIN_ DIGITS - The lengths a SIM PIN may have.