tui/route.rs
1//! Eval reply routing types.
2//!
3//! A `Route` is inserted into `App::pending_routes` when a nomiscript form is
4//! submitted; `drain_eval` removes it on reply and calls `deliver_reply` with
5//! it. `RouteCtx` carries the per-request context needed to parse the reply
6//! correctly when the target view requires more than the wire frame alone.
7
8use crate::tabs::reports::ReportKind;
9use crate::view::ViewId;
10
11/// Which select columns a `FormOptions` reply populates.
12#[derive(Debug, Clone, Copy, PartialEq, Eq)]
13pub enum FormOptionsSource {
14 Accounts,
15 Commodities,
16}
17
18/// Per-reply context a routed eval reply needs to be parsed correctly.
19pub enum RouteCtx {
20 None,
21 Reports {
22 kind: ReportKind,
23 chart: String,
24 },
25 Config {
26 key: String,
27 },
28 /// A create mutation — on success, refresh the given list tab.
29 Mutation {
30 refresh: ViewId,
31 },
32 /// Fetch of select options to populate a currently-open form.
33 ///
34 /// `seq` correlates the reply with the form instance that requested it;
35 /// a late reply for a closed/superseded form is dropped.
36 FormOptions {
37 seq: u64,
38 source: FormOptionsSource,
39 },
40 /// `get-transaction-detail` reply — opens the transaction-edit form on success.
41 TransactionEdit,
42 /// A `convert-amount` query reply — formats a status message, no view refresh.
43 ConvertQuery {
44 amount_str: String,
45 from_label: String,
46 to_label: String,
47 },
48}
49
50/// Maps a pending eval reply id to its destination view and any parse context.
51pub struct Route {
52 pub target: ViewId,
53 pub ctx: RouteCtx,
54}