Skip to main content

UiShared

Struct UiShared 

Source
pub struct UiShared { /* private fields */ }
Expand description

插件面板与宿主观察线程共用的观测状态。

Implementations§

Source§

impl UiShared

Source

pub fn new() -> Self

空状态(快照空、日志空、rev 0)。

Source

pub fn update_tick(&self, t: &TickData)

落一条 tick(eTick. 裸键上屏;逐 symbol 覆盖)。

Source

pub fn tick_rows(&self) -> Vec<TickData>

tick 只读视图(排序后)。

Source

pub fn tick_groups(&self) -> Vec<(String, Vec<TickData>)>

tick 按交易所分组(行情 tab 二级 tab 键表)。

Source

pub fn tick_count(&self) -> usize

tick 库格数。

Source

pub fn order_form(&self) -> OrderForm

下单表单只读快照。

Source

pub fn set_order_form(&self, f: OrderForm)

下单表单写(渲染侧每控件改动即写)。

Source

pub fn selected_exchange(&self) -> String

选中交易所(行情带当前 tab;不在六所内的取值由本口夹回首所 —— 空/脏值 都落到 SHFE,调用方永远拿到一个可用的 tab 名;行情行单击只带入下单面板, tab 归 tab 条管)。

Source

pub fn set_selected_exchange(&self, s: impl Into<String>)

选中交易所写。

Source

pub fn topleft_tab(&self) -> TopLeftTab

左上组当前 tab。

Source

pub fn set_topleft_tab(&self, t: TopLeftTab)

左上组 tab 写。

Source

pub fn bottomright_tab(&self) -> BottomRightTab

右下组当前 tab。

Source

pub fn set_bottomright_tab(&self, t: BottomRightTab)

右下组 tab 写。

Source

pub fn data_split(&self) -> DataSplit

数据区分刀份额读(渲染期)。

Source

pub fn set_data_split(&self, s: DataSplit)

数据区分刀份额写(分隔条拖拽回调;写入前就地夹取到可用区,QSplitter minimumSize 语义 —— 调用方传多少都不出界)。

Source

pub fn reset_layout(&self)

「恢复布局」:数据区分刀回 Python right_splitter 口径(两刀各半), 三个 tab 态回缺省。dock 时代的「整树替换」不再存在 —— 布局骨架本来就是 Python 等价的原生面板,没有树可换。

Source

pub fn ops_window_open(&self) -> bool

运维窗开合。

Source

pub fn table_sort(&self, table: &str) -> Option<(usize, bool)>

运维窗开合写。 某张表当前的排序键(None = 按数据源原序)。

Source

pub fn toggle_table_sort(&self, table: &str, col: usize)

表头点击:同列再点 = 翻向;异列 = 新列升序(与 Python QTableView 单击表头同口径)。

Source

pub fn set_ops_window_open(&self, v: bool)

Source

pub fn accounts_window_open(&self) -> bool

账户面板开合。

Source

pub fn set_accounts_window_open(&self, v: bool)

账户面板开合写。

Source

pub fn account_edit_open(&self) -> bool

账户配置弹窗开合(0.2.18 Commit B)。

Source

pub fn editing_account(&self) -> Option<String>

当前弹窗模式:Some(派生名) = 编辑;None = 添加。

Source

pub fn begin_account_edit(&self, gateway: Option<&str>) -> bool

打开配置弹窗并载入草稿:Some(派生名) = 编辑模式(草稿 = 该账户留档); None = 添加模式(草稿 = draft_from_existing(),凭据位空)。 账户不在清册 = false(不开一个编辑不存在账户的窗)。

Source

pub fn end_account_edit(&self)

关闭配置弹窗 = 放弃未保存(规划 Q24:绝不静默写入清册留档)。

Source

pub fn end_account_edit_if_editing(&self, gateway: &str)

摘除一行账户时的连带口径:若这行正被配置弹窗编辑,立即关弹窗放弃。

不这么做的话:弹窗是非 modal 的,用户可以在弹窗开着时点同一行的『移除』—— 编辑目标消失后弹窗会静默退化成「添加模式」(只读句消失、字段全部可编辑), 此时点『保存』会拿旧凭据建出一个新账户。这是执行核查抓到的坑。

Source

pub fn edit_alias(&self) -> String

弹窗别名草稿读。

Source

pub fn set_edit_alias(&self, v: impl Into<String>)

弹窗别名草稿写。

Source

pub fn edit_error(&self) -> Option<String>

弹窗拦截原因读(None = 无)。

Source

pub fn set_edit_error(&self, e: Option<String>)

弹窗拦截原因写(None = 清)。

Source

pub fn account_edit_dirty(&self) -> bool

弹窗草稿与该账户留档是否不一致(dirty;添加模式恒为“有内容待保存“)。

Source

pub fn accounts(&self) -> Vec<AccountRow>

账户清单只读视图(注册序)。

Source

pub fn account(&self, gateway: &str) -> Option<AccountRow>

单行账户查询。

Source

pub fn add_account(&self, row: AccountRow) -> Result<(), String>

新增一行账户(只写清册,不装配 —— 规划裁定「添加 ≠ 连接」)。

Err(原因) 三种:派生名已存在(同 broker+账号重复添加)、别名重名(规划 Q3)、 达账户软上限 MAX_ACCOUNTS。宿主侧还有第二道 Duplicate 守卫;界面侧先拦是为了 不建出一个“注定被拒“的请求。

Source

pub fn can_add_account(&self) -> bool

是否还能添加账户。

Source

pub fn set_account_alias(&self, gateway: &str, alias: &str) -> bool

改一行账户的别名(按 gateway 主键;不存在 = false)。

别名只用于显示与选择,不参与寻址(寻址恒用派生注册名,规划 Q3)。 别名须唯一(与 add_account 同一守卫):空别名 = 不设别名(合法); 与他人重名 = false(调用方须显形,不得静默改成重名别名)。

Source

pub fn note_connect_sent(&self, gateway: &str)

UiCmd::Connect 已入列 → 四态置「装配中」并清掉上一次的失败原因。

登录态一并退回 Unknown(0.2.19):新一轮装配开始时,上一轮的「在线/掉线」 不再是这一轮的事实 —— 留着会让用户在重连过程中看到「在线」。

Source

pub fn note_connect_result(&self, gateway: &str, result: Result<(), String>)

装配结果回写:Ok(()) → 「实例已装配」;Err(原因) → 「装配失败」+ 原因留显形。

失败不回滚清册行(规划 U3 定盘:行留着,给『重试』;旧口径“必须先移除才能重试“作废)。

Source

pub fn note_effective_product_classes(&self, gateway: &str, classes: &[String])

记录网关实际收录的产品类(ConfigureReply.product_classes 回带,规划 U9)。

只存不改用户勾选:勾选是意图,这一栏是事实,两者并排显示。

Source

pub fn status_thresholds(&self) -> (u32, i64)

当前生效的「查询断供」阈值:(连续被拒次数, 资金回报超时秒)。

Source

pub fn set_status_thresholds(&self, reject_limit: u32, stale_secs: i64)

覆盖阈值(测试夹具把两判据收紧到「1 次 / 0 秒」,才好在没有真柜台的用例里显形)。

Source

pub fn status_poll_due(&self) -> bool

轮询节拍:eTimer 每拍调一次,每 STATUS_POLL_TICKS 拍回一次 true。

Source

pub fn pipeline_poll_due(&self) -> bool

管线装配显形的轮询节拍(0.4.4,P5-a):每 PIPELINE_POLL_TICKS 拍回一次 true。

与状态轮询分两个计数器而不是共用一个:两条节拍不同(2 拍 / 4 拍),共用会让 其中一条被另一条的相位带着走,判据也没法各自钉。

Source

pub fn set_pipeline_lines(&self, lines: Vec<String>)

oms.pipeline_status 读数回写(装配事实,不是业务事实)。

Source

pub fn pipeline_lines(&self) -> Vec<String>

最新一次的 oms 装配显形读数(空 = 运维窗不画这一节)。

Source

pub fn note_trade_frame_stale(&self, stale: bool) -> bool

交易监控帧的「问不到」状态位(0.4.5,P7a)。

旧帧必须被标明是旧的:这一位是渲染侧与日志侧共用的唯一事实。 返回值 = 这是一次迁移(进入或离开 stale)—— 只在迁移那一次落日志, 不每拍刷(拥堵期每拍都问不到,刷 20 分钟就是 1200 条把日志环挤满)。

进入 stale 那一次同时灌一条告警(与 BD-UI-50 同口径:告警是状态口问出来的 事实,不是渲染帧的副作用)。为什么走 toast 而不是在委托表上方挂一句 label: 第五轮审计把委托表表题撤除过(格身份就是 dock tab,再挂同名 label = 三重撞名), 那个位置不许再放东西;toast 画在 Foreground 层,不碰任何布局几何。

Source

pub fn trade_frame_stale(&self) -> bool

交易监控当前显示的是不是上一帧。

Source

pub fn note_plugin_spill(&self, rows: &[PlugRow])

插件邮箱溢出的显形(0.4.5,P7d)。

PlugRow.spilled 是 ek-core 的累计计数(EntryStats.spilled),运维窗那一列 一直有,但当场不响:ek-core 的 stderr 诊断每 128 条才打一条 (SPILL_REPORT_EVERY)。这一条把它变成屏上的一次 toast。 去重口径与 BD-UI-50 同(告警是状态口问出来的事实,不是渲染帧的副作用): 每个插件第一次溢出弹一次;跨过一格邮箱容量再弹一次(持续溢出不刷屏, 但「溢满一整轮」是另一件事 —— 那时丢的已经不是零星几条而是一段时间的行情)。

Source

pub fn note_gateway_status(&self, gateway: &str, st: &GatewayStatus)

{gw}.status 读数回写 → 该行登录态与细节重算。

0.3.2(Wave E,BD-UI-50)这里同时是告警的唯一产生口:轮询一拍问出告警态就灌 toast。 为什么住这儿而不是账户面板的渲染里(Python AlertEngine 的对照口径): 告警是「状态口问出来的事实」,不是「某张窗画出来的东西」——账户窗没开也必须知道掉线了。 去重键 = 网关 + 登录态:同一状态只弹一次,状态变了才算新告警(否则每轮轮询一条, 8 秒自动关与同屏上限 3 都没有意义)。

Source

pub fn note_status_unreachable(&self, gateway: &str, why: &str)

状态口问不到(网关不在场 / ask 超时):登录态退回 Unknown 并写明原因。

不得保留上一轮的「在线」:问不到就是没有证据,留着旧读数等于替网关谎称在线。

Source

pub fn mark_account_stopped(&self, gateway: &str)

『断开』已发令 → 该行立刻显形「已断开」(不等下一轮轮询;用户按了就该马上看到)。

Source

pub fn prepare_connect_form(&self, gateway: &str, form: CtpForm) -> CtpForm

装配前把表单落到该账户留档,并按全局单源纪律裁决 md 位: 非行情源账户 → md_addr 就地清空(留档与下发同一份,消 U4 的“只清下发不清留档“)。

Source

pub fn draft_from_existing(&self) -> CtpForm

『添加账户』弹窗的草稿位:沿用当前在场账户的非凭据字段 (broker / AppID / AuthCode / 收录勾选),凭据位(账号、密码、前置)一律清空 (规划 Q20 的零风险缓解:少敲几遍,但绝不把上一家的密码带进下一家)。

Source

pub fn update_account_form(&self, gateway: &str, form: CtpForm) -> bool

更新一行账户的表单留档(按 gateway 主键;不存在 = false)。

Source

pub fn remove_account(&self, gateway: &str) -> bool

摘除一行账户(界面侧清册;网关实例由 UiCmd::Remove 走 svctl 摘)。

Source

pub fn sync_accounts_connected(&self, rows: &[PlugRow]) -> Vec<String>

用 svctl 快照回填账户在场位与四态;回带本轮新装配的网关名(订阅重放用)。

四态口径:svctl 带回这个名字 = 实例已装配(清掉失败原因); 名字不在场且原先记着「已装配」= 回到「未装配」(被摘/宿主崩了); 「装配中」与「装配失败」是界面侧记的,不被在场表覆盖。

0.2.19 附带一条:实例不在场时登录态读数一并作废 —— 会话读数属于那个实例, 实例没了还留着「在线/掉线 2 次」,就是在替一个不存在的会话说话。

Source

pub fn md_source(&self) -> String

行情元账号注册名(空 = 未选)。

Source

pub fn accounts_locked(&self) -> bool

是否已有账户装配 —— 元账号锁定判定(规划 D3:连接后不允许切换)。

Source

pub fn set_md_source(&self, gateway: &str) -> Result<(), String>

指定行情元账号(仅配置阶段;任何账户已连接 = 拒,界面须提示“先断开“)。

Source

pub fn subscriptions(&self) -> Vec<String>

订阅集只读视图。

Source

pub fn note_subscriptions(&self, symbols: &[String])

登记订阅(去重保序;断开重连后按它重放)。

Source

pub fn default_gateway(&self) -> Option<String>

下单默认账户阶梯(替代旧“空 → 字面量 ctp“兜底,规划 §5.B; 0.2.18 四态后修正,规划 Q4): 上次手动选择(须仍在清册且已装配)→ 第一个已装配账户; 未装配账户不得进默认 —— 旧阶梯的“退到第一个账户“会把只添加了还没连接的 账户选成下单归属,发出去只会撞 unknown:gateway。 一个都没有 = None(界面据此禁用下单钮)。

Source

pub fn kline_symbols(&self) -> Vec<String>

已开 K线窗合约表(多开,去重)。

Source

pub fn open_kline(&self, symbol: impl Into<String>)

开 K线窗(去重;日志留痕可断言)。

Source

pub fn close_kline(&self, symbol: &str)

关 K线窗(窗关闭钮 → 出表)。

Source

pub fn contracts_window_open(&self) -> bool

查询合约窗开合。

Source

pub fn set_contracts_window_open(&self, v: bool)

查询合约窗开合写。

Source

pub fn update_contract(&self, c: &ContractData)

落一条合约(eContract. 裸键上屏)。

Source

pub fn contracts(&self, pattern: &str) -> Vec<ContractData>

合约查询(Python ContractManager 口径:留空 = 全部)。

Source

pub fn contract_count(&self) -> usize

合约库格数。

Source

pub fn contract_query(&self) -> String

查询串读写。

Source

pub fn set_contract_query(&self, q: impl Into<String>)

查询串写。

Source

pub fn toggle_contract_selection(&self, en_symbol: &str)

勾选翻转(en_symbol)。

Source

pub fn selected_contracts(&self) -> Vec<String>

当前勾选集。

Source

pub fn log_line(&self, line: impl Into<String>)

追加一行日志(总线面/宿主观察线程写)。

Source

pub fn clear_logs(&self)

清空日志(渲染“清空日志“按钮 / 测试)。

Source

pub fn logs_snapshot(&self) -> (Vec<String>, u64)

日志只读快照 + 溢出计数。

Source

pub fn logs_entries(&self) -> (Vec<LogEntry>, u64)

带时间戳的日志快照(BD-UI-41 渲染侧:日志表格的「时间」列)。

Source

pub fn logs_len(&self) -> usize

日志当前长度(kittest 断言用)。

Source

pub fn set_snapshot(&self, snap: BusSnap)

落一次服务快照(eTimer 节流回调)。

Source

pub fn snapshot(&self) -> Arc<BusSnap> ⓘ

当前快照(Arc 克隆,零拷贝走锁)。

Source

pub fn rev(&self) -> u64

revision:任何写入 +1(插件面 ePlug 事件也用;测试判定“有事件进来过“)。

Source

pub fn bump(&self)

手动推一次 revision(总线面 ePlugUp/Down 记账用)。

Source

pub fn request_stop(&self)

置关窗信号(eframe App 关窗钩子调用)。

Source

pub fn push_alert(&self, level: AlertLevel, text: impl Into<String>)

观察线程轮询用。 0.3.2(Wave E,BD-UI-50)告警入口:界面层调它,渲染帧灌进 toast 队列。

Source

pub fn alert_once(&self, key: impl Into<String>) -> bool

去重:这条告警第一次出现返回 true(同一键不再重复弹)。

Source

pub fn pending_alert_count(&self) -> usize

待灌进 toast 的告警条数(状态层判据用;灌进队列由渲染帧收口)。

Source

pub fn alerted_count(&self) -> usize

已弹过的告警键数(去重账本;判据用它核「同一状态不重复弹」)。

Source

pub fn exit_confirm_open(&self) -> bool

退出确认窗:开 / 关 / 是否已确认放行(0.3.1 BD-UI-49)。

Source

pub fn open_exit_confirm(&self)

Source

pub fn close_exit_confirm(&self)

Source

pub fn exit_confirmed(&self) -> bool

Source

pub fn confirm_exit(&self)

Source

pub fn is_stop(&self) -> bool

Source

pub fn push_cmd(&self, cmd: UiCmd)

入一条操作指令(窗口面离场动作唯一通道;左位不直调)。

Source

pub fn drain_cmds(&self) -> Vec<UiCmd>

取走全部指令(eTimer 节拍辞行)。

Source

pub fn pending_confirm(&self) -> Option<String>

当前待二次确认目标(Some = 二次确认中)。

Source

pub fn confirm_step(&self, name: &str) -> ConfirmStep

确认步进:同名二点 = 发令(Fired),异名 = 迁移(Switched),首点 = 进入待确认。

Source

pub fn confirm_cancel(&self)

清除待确认(取消钮)。

Source

pub fn market(&self) -> &MarketStore

行情库直读(读写两用:worker 写,渲染读)。

Source

pub fn set_trade_snap(&self, ts: TradeSnap)

交易监控快照写(ui 插件 eTimer 拍)。

Source

pub fn trade_snap(&self) -> Arc<TradeSnap> ⓘ

交易监控快照读(渲染)。

Source

pub fn ctp_form(&self) -> CtpForm

CTP 配置表单读(渲染克隆面)。

Source

pub fn set_ctp_form(&self, f: CtpForm)

CTP 配置表单写。

Source

pub fn row_selected(&self, table: &str, key: &str) -> bool

该行是否为所属表的选中行(渲染判断;无键 = 未选)。

Source

pub fn select_row(&self, table: &str, key: &str)

设所属表的选中行(每表一行;同键重复点 = 保持)。

Trait Implementations§

Source§

impl Debug for UiShared

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for UiShared

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more