pub struct ServerState {
pub inner: Arc<Mutex<Inner>>,
pub enable_trading: bool,
pub allow_real_trading: bool,
pub key_store: Arc<KeyStore>,
pub authed_key: Option<Arc<KeyRecord>>,
pub counters: Arc<RuntimeCounters>,
}Expand description
MCP server 运行时状态
Fields§
§inner: Arc<Mutex<Inner>>§enable_trading: bool是否启用交易写工具(place/modify/cancel)。默认 false。旧开关,仅当
key_store.is_configured() == false 时生效。
allow_real_trading: bool是否允许对 real 环境下单。默认 false。旧开关,同上。
key_store: Arc<KeyStore>keys.json 加载的 KeyStore。is_configured() 为 true 时走 scope 授权模式。
authed_key: Option<Arc<KeyRecord>>调用方传入的 API Key 对应的记录;None 表示未提供 key。
counters: Arc<RuntimeCounters>限额运行时(日累计计数器)
Implementations§
Source§impl ServerState
impl ServerState
pub fn new(gateway: String) -> Self
Sourcepub fn with_trading(
self,
enable_trading: bool,
allow_real_trading: bool,
) -> Self
pub fn with_trading( self, enable_trading: bool, allow_real_trading: bool, ) -> Self
启用交易写工具(构造器式链式设置)
Sourcepub fn with_key_store(self, store: Arc<KeyStore>) -> Self
pub fn with_key_store(self, store: Arc<KeyStore>) -> Self
设置 KeyStore(新授权模式)
Sourcepub fn with_authed_key(self, key: Option<Arc<KeyRecord>>) -> Self
pub fn with_authed_key(self, key: Option<Arc<KeyRecord>>) -> Self
设置已通过验证的 API Key 记录
Sourcepub fn is_scope_mode(&self) -> bool
pub fn is_scope_mode(&self) -> bool
是否启用了 scope 授权模式
Sourcepub async fn client(&self) -> Result<Arc<FutuClient>>
pub async fn client(&self) -> Result<Arc<FutuClient>>
获取(或懒加载)网关客户端
Trait Implementations§
Source§impl Clone for ServerState
impl Clone for ServerState
Source§fn clone(&self) -> ServerState
fn clone(&self) -> ServerState
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ServerState
impl !RefUnwindSafe for ServerState
impl Send for ServerState
impl Sync for ServerState
impl Unpin for ServerState
impl !UnwindSafe for ServerState
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
Mutably borrows from an owned value. Read more