Skip to main content

TradeReplayGuard

Struct TradeReplayGuard 

Source
pub struct TradeReplayGuard { /* private fields */ }
Expand description

交易写路径 PacketID 防重放 guard.

C++ IsReplayAttack(nConnID, packetID) 在 PlaceOrder / ModifyOrder 进入 backend 前检查:

  • packetID.connID == actual conn_id
  • 同连接 packetID.serialNo 单调递增

Rust 另有 idempotency cache 用于正常 retry(同 key 返同一 response)。因此 handler 调用顺序应是: 先 idempotency cache hit,再执行本 guard;这样“同 PacketID 的 retry“命中 cache,不会被当作 replay 误拒,而“新请求使用旧 serial“仍会在 backend 前 fail-closed。

Implementations§

Source§

impl TradeReplayGuard

Source

pub fn new() -> Self

Source

pub fn check_packet( &self, actual_conn_id: u64, packet_conn_id: u64, packet_serial_no: u32, ) -> Result<(), TradeReplayError>

检查 FTAPI trade-write Common.PacketID.

(0, 0) 视为非 FTAPI binary surface 的兼容路径(例如 REST JSON 调用未 传 packetID),不参与 replay guard。

serialNo == 0 视为显式 idempotency-key 映射路径:其重放语义是有意 dedup,由幂等 cache 负责,不参与 C++ serial monotonic check。

Trait Implementations§

Source§

impl Debug for TradeReplayGuard

Source§

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

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

impl Default for TradeReplayGuard

Source§

fn default() -> TradeReplayGuard

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

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.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

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