Authenticator

Trait Authenticator 

Source
pub trait Authenticator: Send + Sync {
    // Required methods
    fn base_header(&self) -> HeaderMap;
    fn login<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_td_url<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        broker_id: &'life1 str,
        account_id: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<BrokerInfo>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn get_md_url<'life0, 'async_trait>(
        &'life0 self,
        stock: bool,
        backtest: bool,
    ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn has_feature(&self, feature: &str) -> bool;
    fn has_md_grants(&self, symbols: &[&str]) -> Result<()>;
    fn has_td_grants(&self, symbol: &str) -> Result<()>;
    fn get_auth_id(&self) -> &str;
    fn get_access_token(&self) -> &str;
}
Expand description

认证器接口

Required Methods§

Source

fn base_header(&self) -> HeaderMap

获取包含认证信息的 HTTP Header

Source

fn login<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

执行登录操作

Source

fn get_td_url<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, broker_id: &'life1 str, account_id: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<BrokerInfo>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

获取指定期货公司的交易服务器地址

Source

fn get_md_url<'life0, 'async_trait>( &'life0 self, stock: bool, backtest: bool, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

获取行情服务器地址

Source

fn has_feature(&self, feature: &str) -> bool

检查是否具有指定的功能权限

Source

fn has_md_grants(&self, symbols: &[&str]) -> Result<()>

检查是否有查看指定合约行情数据的权限

Source

fn has_td_grants(&self, symbol: &str) -> Result<()>

检查是否有交易指定合约的权限

Source

fn get_auth_id(&self) -> &str

获取认证 ID

Source

fn get_access_token(&self) -> &str

获取访问令牌

Implementors§