pub trait Tdx {
type Item: ?Sized;
const SEND: &'static [u8];
const TAG: &'static str;
const LEN: usize = _;
// Required methods
fn send(&mut self) -> &[u8] ⓘ;
fn parse(&mut self, response: Vec<u8>);
fn result(&self) -> &Self::Item;
// Provided methods
fn recv(&mut self, tcp: &mut Tcp) -> Result<Vec<u8>> { ... }
fn recv_parsed(&mut self, tcp: &mut Tcp) -> Result<&Self::Item> { ... }
}
Required Associated Types§
Required Associated Constants§
sourceconst SEND: &'static [u8]
const SEND: &'static [u8]
待发送的字节。所有发送请求的字节由两部分组成:
- 固定的默认字节(基本为前半段字节)
- 查询所需的变化的字节(基本为后半段字节)
Tdx::SEND
的作用为默认有效的字节,即发送字节之后会正常响应且数据可以解析,
但是并不保证每次响应的数据完全一致。
比如请求日线时发送字节在当天收盘后是不变的,次日交易日请求得到的数据则可能改变。
如果发送请求的字节有误,则无法得到响应
(比如设置了读取超时,无响应情况下会得到:
WouldBlock
error)。
字节具体的含义见 Implementor 的 Tdx trait 部分的 SEND
文档。
Provided Associated Constants§
Required Methods§
Provided Methods§
sourcefn recv_parsed(&mut self, tcp: &mut Tcp) -> Result<&Self::Item>
fn recv_parsed(&mut self, tcp: &mut Tcp) -> Result<&Self::Item>
得到和解析响应的字节,并返回解析的数据。
Object Safety§
This trait is not object safe.