Skip to main content

AccountRow

Struct AccountRow 

Source
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

Source

pub fn derive(form: &CtpForm) -> Result<Self, String>

由表单派生账户行(派生名唯一入口 = ek_ctp::derived_gateway_name)。

返回 Err(原因) = broker/账号非法或派生名超宿主 32 字符上限; 界面须红字呈现,不得静默替换(规划 §3)。

Source

pub fn status_label(&self) -> String

状态列文案(装配态 + 登录态拼一起)。

「已装配」后面必须跟着登录态,不能光写「已装配」——0.2.18 那条「不得读成在线」 的口径(规划 U5)现在有了真读数才真正立住:没有证据时写「已装配·登录态未知」。 装配段一律走 AccountStage::label(),不在这里重抄一遍文案(两处不同式就是坑)。

Source

pub fn apply_status( &mut self, st: &GatewayStatus, now_ms: i64, reject_limit: u32, stale_secs: i64, )

把 {gw}.status 读数折成界面登录态 + 细节(0.2.19;规划 P3 / Q10)。

判据顺序写明(每条都有理由):

  1. 登录失败先判 —— 网关在登录成功后会清零 td_login_failed,所以它显形就是现在登不上;
  2. 登录着 → 才谈「查询断供」,三条判据:连续被拒达阈 / 距最后一次资金回报超时 / 登录后资金回报从未到手且已超过同一个 stale 阈值(0.2.21,实连 S15f 逼出来的第三条); 都没中 = 在线;
  3. 没登录 → 用户主动『断开』优先(那是自己按的钮,比柜台掉线计数更贴近用户意图), 其次才是柜台掉线(disconnects > 0),最后才是「未知」;
  4. 纯行情账户(td 前置留档为空)看 MD 半边 —— 看 TD 半边永远是「未知」,那是假信息。

「从未发生」= None 不当 0 用:网关没回报过资金时刻 ≠ 「0 秒前刚回报过」。

Source

pub fn display_name(&self) -> String

显示名:别名优先,空则回退账号(寻址仍只用 gateway,规划 Q3)。

Trait Implementations§

Source§

impl Clone for AccountRow

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AccountRow

Source§

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

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

impl Default for AccountRow

Source§

fn default() -> Self

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

impl PartialEq for AccountRow

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for AccountRow

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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