pub struct NNHeader {
pub proto_ver: u8,
pub client_type: u8,
pub client_ver: u16,
pub lang_id: u8,
pub user_id: u32,
pub is_push: bool,
pub is_compressed: bool,
pub serial_no: u32,
pub cmd_id: u16,
pub body_len: u32,
pub reserved: [u8; 8],
pub ex_head_len: u16,
}Expand description
内部协议帧头
Fields§
§proto_ver: u8§client_type: u8§client_ver: u16§lang_id: u8§user_id: u32§is_push: boolC++ ProtocolHeader::flags_.push_.
is_compressed: boolC++ ProtocolHeader::flags_.compress_.
serial_no: u32§cmd_id: u16§body_len: u32真实 body 长度(不含 ex_head)—— 对齐 C++ GetBodyLen() 语义
reserved: [u8; 8]reserved 8 字节,行情命令用 [0]=market_type [1]=ex_type 注意:C++ reserved 只有 8 字节,后 2 字节是 ex_head_len
ex_head_len: u16扩展头长度(FtnnExtendHead protobuf 序列化后字节数)
Implementations§
Source§impl NNHeader
impl NNHeader
pub fn new(cmd_id: u16, serial_no: u32) -> Self
Sourcepub fn encode(&self, dst: &mut BytesMut)
pub fn encode(&self, dst: &mut BytesMut)
编码到字节流。body_len 字段按真实 body 长度传入(不含 ex_head),
实际上线时我们 不发送 ex_head(ex_head_len=0),所以 wire 上的
ex_head_body_len = body_len。
pub fn decode(src: &BytesMut) -> Result<Option<Self>, FutuError>
pub fn is_compressed(&self) -> bool
pub fn flags(&self) -> u8
Trait Implementations§
Auto Trait Implementations§
impl Freeze for NNHeader
impl RefUnwindSafe for NNHeader
impl Send for NNHeader
impl Sync for NNHeader
impl Unpin for NNHeader
impl UnsafeUnpin for NNHeader
impl UnwindSafe for NNHeader
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