pub struct AccountRow {
pub gateway: String,
pub alias: String,
pub broker_id: String,
pub account: String,
pub md_source: bool,
pub form: CtpForm,
pub stage: AccountStage,
pub fail_note: Option<String>,
pub effective_classes: Vec<String>,
pub connected: bool,
pub login: LoginState,
pub status_note: Option<String>,
}Expand description
账户行(多账号面;规划 §5.B + 0.2.18 四态)。
界面是账户清单的唯一事实源(不新增“账户注册表“插件):
网关实例的在场由 svctl.list 回填,身份与凭据留在这一行,每账户一份 form
(旧「全界面共享一张表单」已退役 → 消 U4 凭据串味 / U6 取消编辑不清空)。
Fields§
§gateway: String派生注册名(ctp_<broker>_<账号>;寻址唯一用这个,别名不参与)。
alias: String用户别名(显示用,可空 = 回退账号;唯一性由 add_account 校验,规划 Q3)。
broker_id: String§account: String§md_source: bool是否行情元账号(全局单源——用户裁定“单数据源“;已装配后锁定,规划 D3)。
form: CtpForm该账户自己的表单留档(编辑弹窗回填用;密码只存内存,裁定 2:不持久化)。
stage: AccountStage装配四态(规划 §3.3)。
fail_note: Option<String>装配失败原因(AssembleFailed 时留显形;成功即清空)。
effective_classes: Vec<String>网关实际收录回带值(ConfigureReply.product_classes,规划 U9)。
与 form.accept_*(用户勾选)并排显示:勾选是意图,这一栏是事实。
空 = 尚未装配过或旧版网关未回带。
connected: bool在场位(由 svctl.list 快照回填:该注册名在不在 = 实例已装配)。
0.2.19 起登录成败另有事实源({gw}.status → login),这一位只管实例。
login: LoginState登录态(0.2.19):{gw}.status 读数折出来的,与 stage/connected 正交。
默认 Unknown:装配成功本身不构成任何登录证据(ek-ctp D-STATUS ①)。
status_note: Option<String>状态细节(「掉线 2 次」「查询连续被拒 3 次」「资金回报已 45s 未更新」)。
None = 没有可说的细节(不是「一切正常」——一切正常由 login 说)。
Implementations§
Source§impl AccountRow
impl AccountRow
Sourcepub fn derive(form: &CtpForm) -> Result<Self, String>
pub fn derive(form: &CtpForm) -> Result<Self, String>
由表单派生账户行(派生名唯一入口 = ek_ctp::derived_gateway_name)。
返回 Err(原因) = broker/账号非法或派生名超宿主 32 字符上限;
界面须红字呈现,不得静默替换(规划 §3)。
Sourcepub fn status_label(&self) -> String
pub fn status_label(&self) -> String
状态列文案(装配态 + 登录态拼一起)。
「已装配」后面必须跟着登录态,不能光写「已装配」——0.2.18 那条「不得读成在线」
的口径(规划 U5)现在有了真读数才真正立住:没有证据时写「已装配·登录态未知」。
装配段一律走 AccountStage::label(),不在这里重抄一遍文案(两处不同式就是坑)。
Sourcepub fn apply_status(
&mut self,
st: &GatewayStatus,
now_ms: i64,
reject_limit: u32,
stale_secs: i64,
)
pub fn apply_status( &mut self, st: &GatewayStatus, now_ms: i64, reject_limit: u32, stale_secs: i64, )
把 {gw}.status 读数折成界面登录态 + 细节(0.2.19;规划 P3 / Q10)。
判据顺序写明(每条都有理由):
- 登录失败先判 —— 网关在登录成功后会清零
td_login_failed,所以它显形就是现在登不上; - 登录着 → 才谈「查询断供」(连续被拒达阈 或 资金回报超时);都没中 = 在线;
- 没登录 → 用户主动『断开』优先(那是自己按的钮,比柜台掉线计数更贴近用户意图),
其次才是柜台掉线(
disconnects > 0),最后才是「未知」; - 纯行情账户(td 前置留档为空)看 MD 半边 —— 看 TD 半边永远是「未知」,那是假信息。
「从未发生」= None 不当 0 用:网关没回报过资金时刻 ≠ 「0 秒前刚回报过」。
Sourcepub fn display_name(&self) -> String
pub fn display_name(&self) -> String
显示名:别名优先,空则回退账号(寻址仍只用 gateway,规划 Q3)。
Trait Implementations§
Source§impl Clone for AccountRow
impl Clone for AccountRow
Source§impl Debug for AccountRow
impl Debug for AccountRow
Source§impl Default for AccountRow
impl Default for AccountRow
Source§impl PartialEq for AccountRow
impl PartialEq for AccountRow
impl StructuralPartialEq for AccountRow
Auto Trait Implementations§
impl Freeze for AccountRow
impl RefUnwindSafe for AccountRow
impl Send for AccountRow
impl Sync for AccountRow
impl Unpin for AccountRow
impl UnsafeUnpin for AccountRow
impl UnwindSafe for AccountRow
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.