pub struct SecurityResolver { /* private fields */ }Expand description
v1.4.106 codex 1148 F5 (P2): 统一 stock_id ↔ Security 双向解析。
使用 Arc<StaticDataCache> 作为底层存储, 不重复持有 cache state — 与现
有 cache 完全 inter-op。可在 handler 构造时 Arc::new(SecurityResolver::new( cache.clone())) 持有, handler 全程调 resolver method 而不直接 touch
cache 字段。
Implementations§
Source§impl SecurityResolver
impl SecurityResolver
pub fn new(cache: Arc<StaticDataCache>) -> Self
Sourcepub fn cache(&self) -> &Arc<StaticDataCache>
pub fn cache(&self) -> &Arc<StaticDataCache>
借用底层 cache (caller 仍能直接 query 其他 method, 比如 trade_dates)。
Sourcepub fn miss_total(&self) -> u64
pub fn miss_total(&self) -> u64
累计 miss 数。
Sourcepub fn resolve_stock_id_by_security(
&self,
security: &SecurityRef<'_>,
) -> Result<u64, ResolverErr>
pub fn resolve_stock_id_by_security( &self, security: &SecurityRef<'_>, ) -> Result<u64, ResolverErr>
C++ GetStockID 等价: Security → stock_id。
Cache hit + info.stock_id > 0 → Ok(stock_id);
其他情况返 ResolverErr (caller 必处理)。
同时触发 mkt_id refresh mark (若 hit 但 mkt_id stale)。
Sourcepub fn resolve_security_by_stock_id(
&self,
stock_id: u64,
) -> Result<CachedSecurityInfo, ResolverErr>
pub fn resolve_security_by_stock_id( &self, stock_id: u64, ) -> Result<CachedSecurityInfo, ResolverErr>
C++ GetAPIStock 等价: stock_id → Security。
Cache hit (id_to_key 含 stock_id 且 securities 含对应 row) → Ok((market, code));
其他情况返 ResolverErr。
同时返 info 引用让 caller 复用 row 字段 (无需第二次 lookup)。
Auto Trait Implementations§
impl !Freeze for SecurityResolver
impl !RefUnwindSafe for SecurityResolver
impl Send for SecurityResolver
impl Sync for SecurityResolver
impl Unpin for SecurityResolver
impl UnsafeUnpin for SecurityResolver
impl !UnwindSafe for SecurityResolver
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