Skip to main content

SecurityResolver

Struct SecurityResolver 

Source
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

Source

pub fn new(cache: Arc<StaticDataCache>) -> Self

Source

pub fn cache(&self) -> &Arc<StaticDataCache>

借用底层 cache (caller 仍能直接 query 其他 method, 比如 trade_dates)。

Source

pub fn miss_total(&self) -> u64

累计 miss 数。

Source

pub fn hit_total(&self) -> u64

累计 hit 数。

Source

pub fn resolve_stock_id_by_security( &self, security: &SecurityRef<'_>, ) -> Result<u64, ResolverErr>

C++ GetStockID 等价: Securitystock_id

Cache hit + info.stock_id > 0Ok(stock_id); 其他情况返 ResolverErr (caller 必处理)。

同时触发 mkt_id refresh mark (若 hit 但 mkt_id stale)。

Source

pub fn resolve_security_by_stock_id( &self, stock_id: u64, ) -> Result<CachedSecurityInfo, ResolverErr>

C++ GetAPIStock 等价: stock_idSecurity

Cache hit (id_to_key 含 stock_id 且 securities 含对应 row) → Ok((market, code)); 其他情况返 ResolverErr

同时返 info 引用让 caller 复用 row 字段 (无需第二次 lookup)。

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more