mirror of
https://github.com/speice-io/marketdata-shootout
synced 2024-11-23 16:38:22 -05:00
Compile schemas for Cap'n'Proto and Flatbuffers
This commit is contained in:
commit
0175a17269
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
/target
|
||||||
|
**/*.rs.bk
|
||||||
|
|
||||||
|
.idea/
|
261
Cargo.lock
generated
Normal file
261
Cargo.lock
generated
Normal file
@ -0,0 +1,261 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
[[package]]
|
||||||
|
name = "ansi_term"
|
||||||
|
version = "0.11.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "atty"
|
||||||
|
version = "0.2.13"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitflags"
|
||||||
|
version = "1.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "capnp"
|
||||||
|
version = "0.10.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "capnpc"
|
||||||
|
version = "0.10.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"capnp 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "0.1.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap"
|
||||||
|
version = "2.33.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "flatbuffers"
|
||||||
|
version = "0.6.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "flatc-rust"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lexical-core"
|
||||||
|
version = "0.4.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"stackvector 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"static_assertions 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libc"
|
||||||
|
version = "0.2.62"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "log"
|
||||||
|
version = "0.4.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "md_shootout"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"capnp 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"capnpc 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"flatbuffers 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"flatc-rust 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"nom 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "memchr"
|
||||||
|
version = "2.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "nom"
|
||||||
|
version = "5.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"lexical-core 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustc_version"
|
||||||
|
version = "0.2.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ryu"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "semver"
|
||||||
|
version = "0.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "semver-parser"
|
||||||
|
version = "0.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "smallvec"
|
||||||
|
version = "0.6.10"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "stackvector"
|
||||||
|
version = "1.0.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "static_assertions"
|
||||||
|
version = "0.3.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "strsim"
|
||||||
|
version = "0.8.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "textwrap"
|
||||||
|
version = "0.11.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-width"
|
||||||
|
version = "0.1.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unreachable"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "vec_map"
|
||||||
|
version = "0.8.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "version_check"
|
||||||
|
version = "0.1.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "void"
|
||||||
|
version = "1.0.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi"
|
||||||
|
version = "0.3.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-i686-pc-windows-gnu"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-x86_64-pc-windows-gnu"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[metadata]
|
||||||
|
"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
|
||||||
|
"checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90"
|
||||||
|
"checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd"
|
||||||
|
"checksum capnp 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a31dc984081bce3531cb7e1c69b5b926904095baf90be9da42df07af54e123a"
|
||||||
|
"checksum capnpc 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6c1a2eead5ee094e8adb30edd6ae55a139b42b8dbe27cc7e4007553ea2b5eb01"
|
||||||
|
"checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33"
|
||||||
|
"checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9"
|
||||||
|
"checksum flatbuffers 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2fc1af59fd8248b59beb048d614a869ce211315c195f5412334e47f5b7e22726"
|
||||||
|
"checksum flatc-rust 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b37a2ed85bee7b6aa0d5305b4765bf4cc0f0cfbc25b86d524126a1ab755f6aed"
|
||||||
|
"checksum lexical-core 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b8b0f90c979adde96d19eb10eb6431ba0c441e2f9e9bdff868b2f6f5114ff519"
|
||||||
|
"checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba"
|
||||||
|
"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
|
||||||
|
"checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e"
|
||||||
|
"checksum nom 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e9761d859320e381010a4f7f8ed425f2c924de33ad121ace447367c713ad561b"
|
||||||
|
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
|
||||||
|
"checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997"
|
||||||
|
"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
|
||||||
|
"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
||||||
|
"checksum smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7"
|
||||||
|
"checksum stackvector 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1c4725650978235083241fab0fdc8e694c3de37821524e7534a1a9061d1068af"
|
||||||
|
"checksum static_assertions 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7f3eb36b47e512f8f1c9e3d10c2c1965bc992bd9cdb024fa581e2194501c83d3"
|
||||||
|
"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
|
||||||
|
"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
|
||||||
|
"checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526"
|
||||||
|
"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56"
|
||||||
|
"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
|
||||||
|
"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd"
|
||||||
|
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
||||||
|
"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770"
|
||||||
|
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||||
|
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
15
Cargo.toml
Normal file
15
Cargo.toml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
[package]
|
||||||
|
name = "md_shootout"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Bradlee Speice <bradlee@speice.io>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
capnp = "0.10.1"
|
||||||
|
clap = "2.33.0"
|
||||||
|
flatbuffers = "0.6.0"
|
||||||
|
nom = "5.0.0"
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
capnpc = "0.10"
|
||||||
|
flatc-rust = "0.1.2"
|
17
build.rs
Normal file
17
build.rs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
extern crate capnpc;
|
||||||
|
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
capnpc::CompilerCommand::new()
|
||||||
|
.src_prefix("")
|
||||||
|
.file("marketdata.capnp")
|
||||||
|
.output_path("src/")
|
||||||
|
.run().expect("Unable to compile capnpc");
|
||||||
|
|
||||||
|
flatc_rust::run(flatc_rust::Args {
|
||||||
|
inputs: &[Path::new("marketdata.fbs")],
|
||||||
|
out_dir: Path::new("src/"),
|
||||||
|
..Default::default()
|
||||||
|
}).expect("Unable to compile flatc");
|
||||||
|
}
|
28
marketdata.capnp
Normal file
28
marketdata.capnp
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
@0x9b88118c58e937dc;
|
||||||
|
|
||||||
|
struct Message {
|
||||||
|
tsNanos @0 :Int64;
|
||||||
|
symbol @1 :Text;
|
||||||
|
|
||||||
|
union {
|
||||||
|
trade @2 :Trade;
|
||||||
|
quote @3 :LevelUpdate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Trade {
|
||||||
|
price @0 :UInt64;
|
||||||
|
size @1 :UInt32;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct LevelUpdate {
|
||||||
|
price @0 :UInt64;
|
||||||
|
size @1 :UInt32;
|
||||||
|
flags @2 :UInt8;
|
||||||
|
side @3 :Side;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Side {
|
||||||
|
buy @0;
|
||||||
|
sell @1;
|
||||||
|
}
|
28
marketdata.fbs
Normal file
28
marketdata.fbs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
namespace MdShootout;
|
||||||
|
|
||||||
|
union MessageBody {
|
||||||
|
Trade, LevelUpdate
|
||||||
|
}
|
||||||
|
|
||||||
|
table Trade {
|
||||||
|
price:uint64;
|
||||||
|
size:uint32;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Side:uint8 {
|
||||||
|
Buy,
|
||||||
|
Sell
|
||||||
|
}
|
||||||
|
|
||||||
|
table LevelUpdate {
|
||||||
|
price:uint64;
|
||||||
|
size:uint32;
|
||||||
|
flags:uint8;
|
||||||
|
side:Side;
|
||||||
|
}
|
||||||
|
|
||||||
|
table Message {
|
||||||
|
ts_nanos:uint64;
|
||||||
|
symbol:string;
|
||||||
|
body:MessageBody;
|
||||||
|
}
|
11
src/main.rs
Normal file
11
src/main.rs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
// Cap'n'Proto and Flatbuffers typically ask that you generate code on the fly to match
|
||||||
|
// the schemas. For purposes of auto-complete and easy browsing in the repository,
|
||||||
|
// we generate the code and just copy it into the src/ tree.
|
||||||
|
pub mod marketdata_capnp;
|
||||||
|
pub mod marketdata_generated; // Flatbuffers
|
||||||
|
|
||||||
|
pub mod marketdata_custom;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
println!("Hello, world!");
|
||||||
|
}
|
550
src/marketdata_capnp.rs
Normal file
550
src/marketdata_capnp.rs
Normal file
@ -0,0 +1,550 @@
|
|||||||
|
// Generated by the capnpc-rust plugin to the Cap'n Proto schema compiler.
|
||||||
|
// DO NOT EDIT.
|
||||||
|
// source: marketdata.capnp
|
||||||
|
|
||||||
|
|
||||||
|
pub mod message {
|
||||||
|
pub use self::Which::{Trade,Quote};
|
||||||
|
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
pub struct Owned;
|
||||||
|
impl <'a> ::capnp::traits::Owned<'a> for Owned { type Reader = Reader<'a>; type Builder = Builder<'a>; }
|
||||||
|
impl <'a> ::capnp::traits::OwnedStruct<'a> for Owned { type Reader = Reader<'a>; type Builder = Builder<'a>; }
|
||||||
|
impl ::capnp::traits::Pipelined for Owned { type Pipeline = Pipeline; }
|
||||||
|
|
||||||
|
#[derive(Clone, Copy)]
|
||||||
|
pub struct Reader<'a> { reader: ::capnp::private::layout::StructReader<'a> }
|
||||||
|
|
||||||
|
impl <'a,> ::capnp::traits::HasTypeId for Reader<'a,> {
|
||||||
|
#[inline]
|
||||||
|
fn type_id() -> u64 { _private::TYPE_ID }
|
||||||
|
}
|
||||||
|
impl <'a,> ::capnp::traits::FromStructReader<'a> for Reader<'a,> {
|
||||||
|
fn new(reader: ::capnp::private::layout::StructReader<'a>) -> Reader<'a,> {
|
||||||
|
Reader { reader: reader, }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl <'a,> ::capnp::traits::FromPointerReader<'a> for Reader<'a,> {
|
||||||
|
fn get_from_pointer(reader: &::capnp::private::layout::PointerReader<'a>, default: ::std::option::Option<&'a [::capnp::Word]>) -> ::capnp::Result<Reader<'a,>> {
|
||||||
|
::std::result::Result::Ok(::capnp::traits::FromStructReader::new(reader.get_struct(default)?))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
|
||||||
|
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
|
||||||
|
self.reader
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl <'a,> ::capnp::traits::Imbue<'a> for Reader<'a,> {
|
||||||
|
fn imbue(&mut self, cap_table: &'a ::capnp::private::layout::CapTable) {
|
||||||
|
self.reader.imbue(::capnp::private::layout::CapTableReader::Plain(cap_table))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl <'a,> Reader<'a,> {
|
||||||
|
pub fn reborrow(&self) -> Reader<> {
|
||||||
|
Reader { .. *self }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> {
|
||||||
|
self.reader.total_size()
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn get_ts_nanos(self) -> i64 {
|
||||||
|
self.reader.get_data_field::<i64>(0)
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn get_symbol(self) -> ::capnp::Result<::capnp::text::Reader<'a>> {
|
||||||
|
::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(0), ::std::option::Option::None)
|
||||||
|
}
|
||||||
|
pub fn has_symbol(&self) -> bool {
|
||||||
|
!self.reader.get_pointer_field(0).is_null()
|
||||||
|
}
|
||||||
|
pub fn has_trade(&self) -> bool {
|
||||||
|
if self.reader.get_data_field::<u16>(4) != 0 { return false; }
|
||||||
|
!self.reader.get_pointer_field(1).is_null()
|
||||||
|
}
|
||||||
|
pub fn has_quote(&self) -> bool {
|
||||||
|
if self.reader.get_data_field::<u16>(4) != 1 { return false; }
|
||||||
|
!self.reader.get_pointer_field(1).is_null()
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn which(self) -> ::std::result::Result<WhichReader<'a,>, ::capnp::NotInSchema> {
|
||||||
|
match self.reader.get_data_field::<u16>(4) {
|
||||||
|
0 => {
|
||||||
|
::std::result::Result::Ok(Trade(
|
||||||
|
::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(1), ::std::option::Option::None)
|
||||||
|
))
|
||||||
|
}
|
||||||
|
1 => {
|
||||||
|
::std::result::Result::Ok(Quote(
|
||||||
|
::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(1), ::std::option::Option::None)
|
||||||
|
))
|
||||||
|
}
|
||||||
|
x => ::std::result::Result::Err(::capnp::NotInSchema(x))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Builder<'a> { builder: ::capnp::private::layout::StructBuilder<'a> }
|
||||||
|
impl <'a,> ::capnp::traits::HasStructSize for Builder<'a,> {
|
||||||
|
#[inline]
|
||||||
|
fn struct_size() -> ::capnp::private::layout::StructSize { _private::STRUCT_SIZE }
|
||||||
|
}
|
||||||
|
impl <'a,> ::capnp::traits::HasTypeId for Builder<'a,> {
|
||||||
|
#[inline]
|
||||||
|
fn type_id() -> u64 { _private::TYPE_ID }
|
||||||
|
}
|
||||||
|
impl <'a,> ::capnp::traits::FromStructBuilder<'a> for Builder<'a,> {
|
||||||
|
fn new(builder: ::capnp::private::layout::StructBuilder<'a>) -> Builder<'a, > {
|
||||||
|
Builder { builder: builder, }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl <'a,> ::capnp::traits::ImbueMut<'a> for Builder<'a,> {
|
||||||
|
fn imbue_mut(&mut self, cap_table: &'a mut ::capnp::private::layout::CapTable) {
|
||||||
|
self.builder.imbue(::capnp::private::layout::CapTableBuilder::Plain(cap_table))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl <'a,> ::capnp::traits::FromPointerBuilder<'a> for Builder<'a,> {
|
||||||
|
fn init_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, _size: u32) -> Builder<'a,> {
|
||||||
|
::capnp::traits::FromStructBuilder::new(builder.init_struct(_private::STRUCT_SIZE))
|
||||||
|
}
|
||||||
|
fn get_from_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, default: ::std::option::Option<&'a [::capnp::Word]>) -> ::capnp::Result<Builder<'a,>> {
|
||||||
|
::std::result::Result::Ok(::capnp::traits::FromStructBuilder::new(builder.get_struct(_private::STRUCT_SIZE, default)?))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl <'a,> ::capnp::traits::SetPointerBuilder<Builder<'a,>> for Reader<'a,> {
|
||||||
|
fn set_pointer_builder<'b>(pointer: ::capnp::private::layout::PointerBuilder<'b>, value: Reader<'a,>, canonicalize: bool) -> ::capnp::Result<()> { pointer.set_struct(&value.reader, canonicalize) }
|
||||||
|
}
|
||||||
|
|
||||||
|
impl <'a,> Builder<'a,> {
|
||||||
|
pub fn into_reader(self) -> Reader<'a,> {
|
||||||
|
::capnp::traits::FromStructReader::new(self.builder.into_reader())
|
||||||
|
}
|
||||||
|
pub fn reborrow(&mut self) -> Builder<> {
|
||||||
|
Builder { .. *self }
|
||||||
|
}
|
||||||
|
pub fn reborrow_as_reader(&self) -> Reader<> {
|
||||||
|
::capnp::traits::FromStructReader::new(self.builder.into_reader())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> {
|
||||||
|
self.builder.into_reader().total_size()
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn get_ts_nanos(self) -> i64 {
|
||||||
|
self.builder.get_data_field::<i64>(0)
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn set_ts_nanos(&mut self, value: i64) {
|
||||||
|
self.builder.set_data_field::<i64>(0, value);
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn get_symbol(self) -> ::capnp::Result<::capnp::text::Builder<'a>> {
|
||||||
|
::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(0), ::std::option::Option::None)
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn set_symbol(&mut self, value: ::capnp::text::Reader) {
|
||||||
|
self.builder.get_pointer_field(0).set_text(value);
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn init_symbol(self, size: u32) -> ::capnp::text::Builder<'a> {
|
||||||
|
self.builder.get_pointer_field(0).init_text(size)
|
||||||
|
}
|
||||||
|
pub fn has_symbol(&self) -> bool {
|
||||||
|
!self.builder.get_pointer_field(0).is_null()
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn set_trade<'b>(&mut self, value: crate::marketdata_capnp::trade::Reader<'b>) -> ::capnp::Result<()> {
|
||||||
|
self.builder.set_data_field::<u16>(4, 0);
|
||||||
|
::capnp::traits::SetPointerBuilder::set_pointer_builder(self.builder.get_pointer_field(1), value, false)
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn init_trade(self, ) -> crate::marketdata_capnp::trade::Builder<'a> {
|
||||||
|
self.builder.set_data_field::<u16>(4, 0);
|
||||||
|
::capnp::traits::FromPointerBuilder::init_pointer(self.builder.get_pointer_field(1), 0)
|
||||||
|
}
|
||||||
|
pub fn has_trade(&self) -> bool {
|
||||||
|
if self.builder.get_data_field::<u16>(4) != 0 { return false; }
|
||||||
|
!self.builder.get_pointer_field(1).is_null()
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn set_quote<'b>(&mut self, value: crate::marketdata_capnp::level_update::Reader<'b>) -> ::capnp::Result<()> {
|
||||||
|
self.builder.set_data_field::<u16>(4, 1);
|
||||||
|
::capnp::traits::SetPointerBuilder::set_pointer_builder(self.builder.get_pointer_field(1), value, false)
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn init_quote(self, ) -> crate::marketdata_capnp::level_update::Builder<'a> {
|
||||||
|
self.builder.set_data_field::<u16>(4, 1);
|
||||||
|
::capnp::traits::FromPointerBuilder::init_pointer(self.builder.get_pointer_field(1), 0)
|
||||||
|
}
|
||||||
|
pub fn has_quote(&self) -> bool {
|
||||||
|
if self.builder.get_data_field::<u16>(4) != 1 { return false; }
|
||||||
|
!self.builder.get_pointer_field(1).is_null()
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn which(self) -> ::std::result::Result<WhichBuilder<'a,>, ::capnp::NotInSchema> {
|
||||||
|
match self.builder.get_data_field::<u16>(4) {
|
||||||
|
0 => {
|
||||||
|
::std::result::Result::Ok(Trade(
|
||||||
|
::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(1), ::std::option::Option::None)
|
||||||
|
))
|
||||||
|
}
|
||||||
|
1 => {
|
||||||
|
::std::result::Result::Ok(Quote(
|
||||||
|
::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(1), ::std::option::Option::None)
|
||||||
|
))
|
||||||
|
}
|
||||||
|
x => ::std::result::Result::Err(::capnp::NotInSchema(x))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Pipeline { _typeless: ::capnp::any_pointer::Pipeline }
|
||||||
|
impl ::capnp::capability::FromTypelessPipeline for Pipeline {
|
||||||
|
fn new(typeless: ::capnp::any_pointer::Pipeline) -> Pipeline {
|
||||||
|
Pipeline { _typeless: typeless, }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl Pipeline {
|
||||||
|
}
|
||||||
|
mod _private {
|
||||||
|
use capnp::private::layout;
|
||||||
|
pub const STRUCT_SIZE: layout::StructSize = layout::StructSize { data: 2, pointers: 2 };
|
||||||
|
pub const TYPE_ID: u64 = 0x91d7_2965_3a3d_4be4;
|
||||||
|
}
|
||||||
|
pub enum Which<A0,A1> {
|
||||||
|
Trade(A0),
|
||||||
|
Quote(A1),
|
||||||
|
}
|
||||||
|
pub type WhichReader<'a,> = Which<::capnp::Result<crate::marketdata_capnp::trade::Reader<'a>>,::capnp::Result<crate::marketdata_capnp::level_update::Reader<'a>>>;
|
||||||
|
pub type WhichBuilder<'a,> = Which<::capnp::Result<crate::marketdata_capnp::trade::Builder<'a>>,::capnp::Result<crate::marketdata_capnp::level_update::Builder<'a>>>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod trade {
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
pub struct Owned;
|
||||||
|
impl <'a> ::capnp::traits::Owned<'a> for Owned { type Reader = Reader<'a>; type Builder = Builder<'a>; }
|
||||||
|
impl <'a> ::capnp::traits::OwnedStruct<'a> for Owned { type Reader = Reader<'a>; type Builder = Builder<'a>; }
|
||||||
|
impl ::capnp::traits::Pipelined for Owned { type Pipeline = Pipeline; }
|
||||||
|
|
||||||
|
#[derive(Clone, Copy)]
|
||||||
|
pub struct Reader<'a> { reader: ::capnp::private::layout::StructReader<'a> }
|
||||||
|
|
||||||
|
impl <'a,> ::capnp::traits::HasTypeId for Reader<'a,> {
|
||||||
|
#[inline]
|
||||||
|
fn type_id() -> u64 { _private::TYPE_ID }
|
||||||
|
}
|
||||||
|
impl <'a,> ::capnp::traits::FromStructReader<'a> for Reader<'a,> {
|
||||||
|
fn new(reader: ::capnp::private::layout::StructReader<'a>) -> Reader<'a,> {
|
||||||
|
Reader { reader: reader, }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl <'a,> ::capnp::traits::FromPointerReader<'a> for Reader<'a,> {
|
||||||
|
fn get_from_pointer(reader: &::capnp::private::layout::PointerReader<'a>, default: ::std::option::Option<&'a [::capnp::Word]>) -> ::capnp::Result<Reader<'a,>> {
|
||||||
|
::std::result::Result::Ok(::capnp::traits::FromStructReader::new(reader.get_struct(default)?))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
|
||||||
|
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
|
||||||
|
self.reader
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl <'a,> ::capnp::traits::Imbue<'a> for Reader<'a,> {
|
||||||
|
fn imbue(&mut self, cap_table: &'a ::capnp::private::layout::CapTable) {
|
||||||
|
self.reader.imbue(::capnp::private::layout::CapTableReader::Plain(cap_table))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl <'a,> Reader<'a,> {
|
||||||
|
pub fn reborrow(&self) -> Reader<> {
|
||||||
|
Reader { .. *self }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> {
|
||||||
|
self.reader.total_size()
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn get_price(self) -> u64 {
|
||||||
|
self.reader.get_data_field::<u64>(0)
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn get_size(self) -> u32 {
|
||||||
|
self.reader.get_data_field::<u32>(2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Builder<'a> { builder: ::capnp::private::layout::StructBuilder<'a> }
|
||||||
|
impl <'a,> ::capnp::traits::HasStructSize for Builder<'a,> {
|
||||||
|
#[inline]
|
||||||
|
fn struct_size() -> ::capnp::private::layout::StructSize { _private::STRUCT_SIZE }
|
||||||
|
}
|
||||||
|
impl <'a,> ::capnp::traits::HasTypeId for Builder<'a,> {
|
||||||
|
#[inline]
|
||||||
|
fn type_id() -> u64 { _private::TYPE_ID }
|
||||||
|
}
|
||||||
|
impl <'a,> ::capnp::traits::FromStructBuilder<'a> for Builder<'a,> {
|
||||||
|
fn new(builder: ::capnp::private::layout::StructBuilder<'a>) -> Builder<'a, > {
|
||||||
|
Builder { builder: builder, }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl <'a,> ::capnp::traits::ImbueMut<'a> for Builder<'a,> {
|
||||||
|
fn imbue_mut(&mut self, cap_table: &'a mut ::capnp::private::layout::CapTable) {
|
||||||
|
self.builder.imbue(::capnp::private::layout::CapTableBuilder::Plain(cap_table))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl <'a,> ::capnp::traits::FromPointerBuilder<'a> for Builder<'a,> {
|
||||||
|
fn init_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, _size: u32) -> Builder<'a,> {
|
||||||
|
::capnp::traits::FromStructBuilder::new(builder.init_struct(_private::STRUCT_SIZE))
|
||||||
|
}
|
||||||
|
fn get_from_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, default: ::std::option::Option<&'a [::capnp::Word]>) -> ::capnp::Result<Builder<'a,>> {
|
||||||
|
::std::result::Result::Ok(::capnp::traits::FromStructBuilder::new(builder.get_struct(_private::STRUCT_SIZE, default)?))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl <'a,> ::capnp::traits::SetPointerBuilder<Builder<'a,>> for Reader<'a,> {
|
||||||
|
fn set_pointer_builder<'b>(pointer: ::capnp::private::layout::PointerBuilder<'b>, value: Reader<'a,>, canonicalize: bool) -> ::capnp::Result<()> { pointer.set_struct(&value.reader, canonicalize) }
|
||||||
|
}
|
||||||
|
|
||||||
|
impl <'a,> Builder<'a,> {
|
||||||
|
pub fn into_reader(self) -> Reader<'a,> {
|
||||||
|
::capnp::traits::FromStructReader::new(self.builder.into_reader())
|
||||||
|
}
|
||||||
|
pub fn reborrow(&mut self) -> Builder<> {
|
||||||
|
Builder { .. *self }
|
||||||
|
}
|
||||||
|
pub fn reborrow_as_reader(&self) -> Reader<> {
|
||||||
|
::capnp::traits::FromStructReader::new(self.builder.into_reader())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> {
|
||||||
|
self.builder.into_reader().total_size()
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn get_price(self) -> u64 {
|
||||||
|
self.builder.get_data_field::<u64>(0)
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn set_price(&mut self, value: u64) {
|
||||||
|
self.builder.set_data_field::<u64>(0, value);
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn get_size(self) -> u32 {
|
||||||
|
self.builder.get_data_field::<u32>(2)
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn set_size(&mut self, value: u32) {
|
||||||
|
self.builder.set_data_field::<u32>(2, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Pipeline { _typeless: ::capnp::any_pointer::Pipeline }
|
||||||
|
impl ::capnp::capability::FromTypelessPipeline for Pipeline {
|
||||||
|
fn new(typeless: ::capnp::any_pointer::Pipeline) -> Pipeline {
|
||||||
|
Pipeline { _typeless: typeless, }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl Pipeline {
|
||||||
|
}
|
||||||
|
mod _private {
|
||||||
|
use capnp::private::layout;
|
||||||
|
pub const STRUCT_SIZE: layout::StructSize = layout::StructSize { data: 2, pointers: 0 };
|
||||||
|
pub const TYPE_ID: u64 = 0xd29e_10bd_4e5f_c241;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod level_update {
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
pub struct Owned;
|
||||||
|
impl <'a> ::capnp::traits::Owned<'a> for Owned { type Reader = Reader<'a>; type Builder = Builder<'a>; }
|
||||||
|
impl <'a> ::capnp::traits::OwnedStruct<'a> for Owned { type Reader = Reader<'a>; type Builder = Builder<'a>; }
|
||||||
|
impl ::capnp::traits::Pipelined for Owned { type Pipeline = Pipeline; }
|
||||||
|
|
||||||
|
#[derive(Clone, Copy)]
|
||||||
|
pub struct Reader<'a> { reader: ::capnp::private::layout::StructReader<'a> }
|
||||||
|
|
||||||
|
impl <'a,> ::capnp::traits::HasTypeId for Reader<'a,> {
|
||||||
|
#[inline]
|
||||||
|
fn type_id() -> u64 { _private::TYPE_ID }
|
||||||
|
}
|
||||||
|
impl <'a,> ::capnp::traits::FromStructReader<'a> for Reader<'a,> {
|
||||||
|
fn new(reader: ::capnp::private::layout::StructReader<'a>) -> Reader<'a,> {
|
||||||
|
Reader { reader: reader, }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl <'a,> ::capnp::traits::FromPointerReader<'a> for Reader<'a,> {
|
||||||
|
fn get_from_pointer(reader: &::capnp::private::layout::PointerReader<'a>, default: ::std::option::Option<&'a [::capnp::Word]>) -> ::capnp::Result<Reader<'a,>> {
|
||||||
|
::std::result::Result::Ok(::capnp::traits::FromStructReader::new(reader.get_struct(default)?))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
|
||||||
|
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
|
||||||
|
self.reader
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl <'a,> ::capnp::traits::Imbue<'a> for Reader<'a,> {
|
||||||
|
fn imbue(&mut self, cap_table: &'a ::capnp::private::layout::CapTable) {
|
||||||
|
self.reader.imbue(::capnp::private::layout::CapTableReader::Plain(cap_table))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl <'a,> Reader<'a,> {
|
||||||
|
pub fn reborrow(&self) -> Reader<> {
|
||||||
|
Reader { .. *self }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> {
|
||||||
|
self.reader.total_size()
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn get_price(self) -> u64 {
|
||||||
|
self.reader.get_data_field::<u64>(0)
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn get_size(self) -> u32 {
|
||||||
|
self.reader.get_data_field::<u32>(2)
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn get_flags(self) -> u8 {
|
||||||
|
self.reader.get_data_field::<u8>(12)
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn get_side(self) -> ::std::result::Result<crate::marketdata_capnp::Side,::capnp::NotInSchema> {
|
||||||
|
::capnp::traits::FromU16::from_u16(self.reader.get_data_field::<u16>(7))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Builder<'a> { builder: ::capnp::private::layout::StructBuilder<'a> }
|
||||||
|
impl <'a,> ::capnp::traits::HasStructSize for Builder<'a,> {
|
||||||
|
#[inline]
|
||||||
|
fn struct_size() -> ::capnp::private::layout::StructSize { _private::STRUCT_SIZE }
|
||||||
|
}
|
||||||
|
impl <'a,> ::capnp::traits::HasTypeId for Builder<'a,> {
|
||||||
|
#[inline]
|
||||||
|
fn type_id() -> u64 { _private::TYPE_ID }
|
||||||
|
}
|
||||||
|
impl <'a,> ::capnp::traits::FromStructBuilder<'a> for Builder<'a,> {
|
||||||
|
fn new(builder: ::capnp::private::layout::StructBuilder<'a>) -> Builder<'a, > {
|
||||||
|
Builder { builder: builder, }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl <'a,> ::capnp::traits::ImbueMut<'a> for Builder<'a,> {
|
||||||
|
fn imbue_mut(&mut self, cap_table: &'a mut ::capnp::private::layout::CapTable) {
|
||||||
|
self.builder.imbue(::capnp::private::layout::CapTableBuilder::Plain(cap_table))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl <'a,> ::capnp::traits::FromPointerBuilder<'a> for Builder<'a,> {
|
||||||
|
fn init_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, _size: u32) -> Builder<'a,> {
|
||||||
|
::capnp::traits::FromStructBuilder::new(builder.init_struct(_private::STRUCT_SIZE))
|
||||||
|
}
|
||||||
|
fn get_from_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, default: ::std::option::Option<&'a [::capnp::Word]>) -> ::capnp::Result<Builder<'a,>> {
|
||||||
|
::std::result::Result::Ok(::capnp::traits::FromStructBuilder::new(builder.get_struct(_private::STRUCT_SIZE, default)?))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl <'a,> ::capnp::traits::SetPointerBuilder<Builder<'a,>> for Reader<'a,> {
|
||||||
|
fn set_pointer_builder<'b>(pointer: ::capnp::private::layout::PointerBuilder<'b>, value: Reader<'a,>, canonicalize: bool) -> ::capnp::Result<()> { pointer.set_struct(&value.reader, canonicalize) }
|
||||||
|
}
|
||||||
|
|
||||||
|
impl <'a,> Builder<'a,> {
|
||||||
|
pub fn into_reader(self) -> Reader<'a,> {
|
||||||
|
::capnp::traits::FromStructReader::new(self.builder.into_reader())
|
||||||
|
}
|
||||||
|
pub fn reborrow(&mut self) -> Builder<> {
|
||||||
|
Builder { .. *self }
|
||||||
|
}
|
||||||
|
pub fn reborrow_as_reader(&self) -> Reader<> {
|
||||||
|
::capnp::traits::FromStructReader::new(self.builder.into_reader())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> {
|
||||||
|
self.builder.into_reader().total_size()
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn get_price(self) -> u64 {
|
||||||
|
self.builder.get_data_field::<u64>(0)
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn set_price(&mut self, value: u64) {
|
||||||
|
self.builder.set_data_field::<u64>(0, value);
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn get_size(self) -> u32 {
|
||||||
|
self.builder.get_data_field::<u32>(2)
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn set_size(&mut self, value: u32) {
|
||||||
|
self.builder.set_data_field::<u32>(2, value);
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn get_flags(self) -> u8 {
|
||||||
|
self.builder.get_data_field::<u8>(12)
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn set_flags(&mut self, value: u8) {
|
||||||
|
self.builder.set_data_field::<u8>(12, value);
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn get_side(self) -> ::std::result::Result<crate::marketdata_capnp::Side,::capnp::NotInSchema> {
|
||||||
|
::capnp::traits::FromU16::from_u16(self.builder.get_data_field::<u16>(7))
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn set_side(&mut self, value: crate::marketdata_capnp::Side) {
|
||||||
|
self.builder.set_data_field::<u16>(7, value as u16)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Pipeline { _typeless: ::capnp::any_pointer::Pipeline }
|
||||||
|
impl ::capnp::capability::FromTypelessPipeline for Pipeline {
|
||||||
|
fn new(typeless: ::capnp::any_pointer::Pipeline) -> Pipeline {
|
||||||
|
Pipeline { _typeless: typeless, }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl Pipeline {
|
||||||
|
}
|
||||||
|
mod _private {
|
||||||
|
use capnp::private::layout;
|
||||||
|
pub const STRUCT_SIZE: layout::StructSize = layout::StructSize { data: 2, pointers: 0 };
|
||||||
|
pub const TYPE_ID: u64 = 0xe664_c3b5_6628_c453;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[repr(u16)]
|
||||||
|
#[derive(Clone, Copy, PartialEq)]
|
||||||
|
pub enum Side {
|
||||||
|
Buy = 0,
|
||||||
|
Sell = 1,
|
||||||
|
}
|
||||||
|
impl ::capnp::traits::FromU16 for Side {
|
||||||
|
#[inline]
|
||||||
|
fn from_u16(value: u16) -> ::std::result::Result<Side, ::capnp::NotInSchema> {
|
||||||
|
match value {
|
||||||
|
0 => ::std::result::Result::Ok(Side::Buy),
|
||||||
|
1 => ::std::result::Result::Ok(Side::Sell),
|
||||||
|
n => ::std::result::Result::Err(::capnp::NotInSchema(n)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl ::capnp::traits::ToU16 for Side {
|
||||||
|
#[inline]
|
||||||
|
fn to_u16(self) -> u16 { self as u16 }
|
||||||
|
}
|
||||||
|
impl ::capnp::traits::HasTypeId for Side {
|
||||||
|
#[inline]
|
||||||
|
fn type_id() -> u64 { 0xd3ce_49cb_99f0_f929u64 }
|
||||||
|
}
|
46
src/marketdata_custom.rs
Normal file
46
src/marketdata_custom.rs
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
// This is hand-written code to act as proof-of-concept
|
||||||
|
// for a more complex schema generator. Theoretically, the
|
||||||
|
// schema file that would be used to generate the code below
|
||||||
|
// looks something like this (influenced by Kaitai Struct):
|
||||||
|
//
|
||||||
|
// seq:
|
||||||
|
// - id: ts_nanos
|
||||||
|
// type: u64
|
||||||
|
// - id: symbol
|
||||||
|
// type: str
|
||||||
|
// - id: msg_type
|
||||||
|
// type: u8
|
||||||
|
// enum: msg_type
|
||||||
|
// - id: msg_body
|
||||||
|
// type:
|
||||||
|
// switch-on: msg_type
|
||||||
|
// cases:
|
||||||
|
// msg_type::trade: trade
|
||||||
|
// msg_type::level_update: level_update
|
||||||
|
// enums:
|
||||||
|
// msg_type:
|
||||||
|
// 0: trade
|
||||||
|
// 1: level_update
|
||||||
|
//
|
||||||
|
// side:
|
||||||
|
// 0: buy
|
||||||
|
// 1: sell
|
||||||
|
//
|
||||||
|
// types:
|
||||||
|
// trade:
|
||||||
|
// seq:
|
||||||
|
// - id: price
|
||||||
|
// type: u64
|
||||||
|
// - id: size
|
||||||
|
// type: u32
|
||||||
|
// level_update:
|
||||||
|
// seq:
|
||||||
|
// - id: price
|
||||||
|
// type: u64
|
||||||
|
// - id: size
|
||||||
|
// type: u32
|
||||||
|
// - id: flags
|
||||||
|
// type: u8
|
||||||
|
// - id: side
|
||||||
|
// type: u8
|
||||||
|
// enum: side
|
477
src/marketdata_generated.rs
Normal file
477
src/marketdata_generated.rs
Normal file
@ -0,0 +1,477 @@
|
|||||||
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
use std::mem;
|
||||||
|
use std::cmp::Ordering;
|
||||||
|
|
||||||
|
extern crate flatbuffers;
|
||||||
|
use self::flatbuffers::EndianScalar;
|
||||||
|
|
||||||
|
#[allow(unused_imports, dead_code)]
|
||||||
|
pub mod md_shootout {
|
||||||
|
|
||||||
|
use std::mem;
|
||||||
|
use std::cmp::Ordering;
|
||||||
|
|
||||||
|
extern crate flatbuffers;
|
||||||
|
use self::flatbuffers::EndianScalar;
|
||||||
|
|
||||||
|
#[allow(non_camel_case_types)]
|
||||||
|
#[repr(u8)]
|
||||||
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
||||||
|
pub enum MessageBody {
|
||||||
|
NONE = 0,
|
||||||
|
Trade = 1,
|
||||||
|
LevelUpdate = 2,
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const ENUM_MIN_MESSAGE_BODY: u8 = 0;
|
||||||
|
const ENUM_MAX_MESSAGE_BODY: u8 = 2;
|
||||||
|
|
||||||
|
impl<'a> flatbuffers::Follow<'a> for MessageBody {
|
||||||
|
type Inner = Self;
|
||||||
|
#[inline]
|
||||||
|
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
|
flatbuffers::read_scalar_at::<Self>(buf, loc)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl flatbuffers::EndianScalar for MessageBody {
|
||||||
|
#[inline]
|
||||||
|
fn to_little_endian(self) -> Self {
|
||||||
|
let n = u8::to_le(self as u8);
|
||||||
|
let p = &n as *const u8 as *const MessageBody;
|
||||||
|
unsafe { *p }
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
fn from_little_endian(self) -> Self {
|
||||||
|
let n = u8::from_le(self as u8);
|
||||||
|
let p = &n as *const u8 as *const MessageBody;
|
||||||
|
unsafe { *p }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl flatbuffers::Push for MessageBody {
|
||||||
|
type Output = MessageBody;
|
||||||
|
#[inline]
|
||||||
|
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
|
||||||
|
flatbuffers::emplace_scalar::<MessageBody>(dst, *self);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(non_camel_case_types)]
|
||||||
|
const ENUM_VALUES_MESSAGE_BODY:[MessageBody; 3] = [
|
||||||
|
MessageBody::NONE,
|
||||||
|
MessageBody::Trade,
|
||||||
|
MessageBody::LevelUpdate
|
||||||
|
];
|
||||||
|
|
||||||
|
#[allow(non_camel_case_types)]
|
||||||
|
const ENUM_NAMES_MESSAGE_BODY:[&'static str; 3] = [
|
||||||
|
"NONE",
|
||||||
|
"Trade",
|
||||||
|
"LevelUpdate"
|
||||||
|
];
|
||||||
|
|
||||||
|
pub fn enum_name_message_body(e: MessageBody) -> &'static str {
|
||||||
|
let index = e as u8;
|
||||||
|
ENUM_NAMES_MESSAGE_BODY[index as usize]
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct MessageBodyUnionTableOffset {}
|
||||||
|
#[allow(non_camel_case_types)]
|
||||||
|
#[repr(u8)]
|
||||||
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
||||||
|
pub enum Side {
|
||||||
|
Buy = 0,
|
||||||
|
Sell = 1,
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const ENUM_MIN_SIDE: u8 = 0;
|
||||||
|
const ENUM_MAX_SIDE: u8 = 1;
|
||||||
|
|
||||||
|
impl<'a> flatbuffers::Follow<'a> for Side {
|
||||||
|
type Inner = Self;
|
||||||
|
#[inline]
|
||||||
|
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
|
flatbuffers::read_scalar_at::<Self>(buf, loc)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl flatbuffers::EndianScalar for Side {
|
||||||
|
#[inline]
|
||||||
|
fn to_little_endian(self) -> Self {
|
||||||
|
let n = u8::to_le(self as u8);
|
||||||
|
let p = &n as *const u8 as *const Side;
|
||||||
|
unsafe { *p }
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
fn from_little_endian(self) -> Self {
|
||||||
|
let n = u8::from_le(self as u8);
|
||||||
|
let p = &n as *const u8 as *const Side;
|
||||||
|
unsafe { *p }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl flatbuffers::Push for Side {
|
||||||
|
type Output = Side;
|
||||||
|
#[inline]
|
||||||
|
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
|
||||||
|
flatbuffers::emplace_scalar::<Side>(dst, *self);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(non_camel_case_types)]
|
||||||
|
const ENUM_VALUES_SIDE:[Side; 2] = [
|
||||||
|
Side::Buy,
|
||||||
|
Side::Sell
|
||||||
|
];
|
||||||
|
|
||||||
|
#[allow(non_camel_case_types)]
|
||||||
|
const ENUM_NAMES_SIDE:[&'static str; 2] = [
|
||||||
|
"Buy",
|
||||||
|
"Sell"
|
||||||
|
];
|
||||||
|
|
||||||
|
pub fn enum_name_side(e: Side) -> &'static str {
|
||||||
|
let index = e as u8;
|
||||||
|
ENUM_NAMES_SIDE[index as usize]
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum TradeOffset {}
|
||||||
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||||
|
|
||||||
|
pub struct Trade<'a> {
|
||||||
|
pub _tab: flatbuffers::Table<'a>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> flatbuffers::Follow<'a> for Trade<'a> {
|
||||||
|
type Inner = Trade<'a>;
|
||||||
|
#[inline]
|
||||||
|
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
|
Self {
|
||||||
|
_tab: flatbuffers::Table { buf: buf, loc: loc },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> Trade<'a> {
|
||||||
|
#[inline]
|
||||||
|
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||||
|
Trade {
|
||||||
|
_tab: table,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[allow(unused_mut)]
|
||||||
|
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||||
|
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||||
|
args: &'args TradeArgs) -> flatbuffers::WIPOffset<Trade<'bldr>> {
|
||||||
|
let mut builder = TradeBuilder::new(_fbb);
|
||||||
|
builder.add_price(args.price);
|
||||||
|
builder.add_size_(args.size_);
|
||||||
|
builder.finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const VT_PRICE: flatbuffers::VOffsetT = 4;
|
||||||
|
pub const VT_SIZE_: flatbuffers::VOffsetT = 6;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn price(&self) -> u64 {
|
||||||
|
self._tab.get::<u64>(Trade::VT_PRICE, Some(0)).unwrap()
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn size_(&self) -> u32 {
|
||||||
|
self._tab.get::<u32>(Trade::VT_SIZE_, Some(0)).unwrap()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct TradeArgs {
|
||||||
|
pub price: u64,
|
||||||
|
pub size_: u32,
|
||||||
|
}
|
||||||
|
impl<'a> Default for TradeArgs {
|
||||||
|
#[inline]
|
||||||
|
fn default() -> Self {
|
||||||
|
TradeArgs {
|
||||||
|
price: 0,
|
||||||
|
size_: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub struct TradeBuilder<'a: 'b, 'b> {
|
||||||
|
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||||
|
start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
|
||||||
|
}
|
||||||
|
impl<'a: 'b, 'b> TradeBuilder<'a, 'b> {
|
||||||
|
#[inline]
|
||||||
|
pub fn add_price(&mut self, price: u64) {
|
||||||
|
self.fbb_.push_slot::<u64>(Trade::VT_PRICE, price, 0);
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn add_size_(&mut self, size_: u32) {
|
||||||
|
self.fbb_.push_slot::<u32>(Trade::VT_SIZE_, size_, 0);
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> TradeBuilder<'a, 'b> {
|
||||||
|
let start = _fbb.start_table();
|
||||||
|
TradeBuilder {
|
||||||
|
fbb_: _fbb,
|
||||||
|
start_: start,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn finish(self) -> flatbuffers::WIPOffset<Trade<'a>> {
|
||||||
|
let o = self.fbb_.end_table(self.start_);
|
||||||
|
flatbuffers::WIPOffset::new(o.value())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum LevelUpdateOffset {}
|
||||||
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||||
|
|
||||||
|
pub struct LevelUpdate<'a> {
|
||||||
|
pub _tab: flatbuffers::Table<'a>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> flatbuffers::Follow<'a> for LevelUpdate<'a> {
|
||||||
|
type Inner = LevelUpdate<'a>;
|
||||||
|
#[inline]
|
||||||
|
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
|
Self {
|
||||||
|
_tab: flatbuffers::Table { buf: buf, loc: loc },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> LevelUpdate<'a> {
|
||||||
|
#[inline]
|
||||||
|
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||||
|
LevelUpdate {
|
||||||
|
_tab: table,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[allow(unused_mut)]
|
||||||
|
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||||
|
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||||
|
args: &'args LevelUpdateArgs) -> flatbuffers::WIPOffset<LevelUpdate<'bldr>> {
|
||||||
|
let mut builder = LevelUpdateBuilder::new(_fbb);
|
||||||
|
builder.add_price(args.price);
|
||||||
|
builder.add_size_(args.size_);
|
||||||
|
builder.add_side(args.side);
|
||||||
|
builder.add_flags(args.flags);
|
||||||
|
builder.finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const VT_PRICE: flatbuffers::VOffsetT = 4;
|
||||||
|
pub const VT_SIZE_: flatbuffers::VOffsetT = 6;
|
||||||
|
pub const VT_FLAGS: flatbuffers::VOffsetT = 8;
|
||||||
|
pub const VT_SIDE: flatbuffers::VOffsetT = 10;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn price(&self) -> u64 {
|
||||||
|
self._tab.get::<u64>(LevelUpdate::VT_PRICE, Some(0)).unwrap()
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn size_(&self) -> u32 {
|
||||||
|
self._tab.get::<u32>(LevelUpdate::VT_SIZE_, Some(0)).unwrap()
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn flags(&self) -> u8 {
|
||||||
|
self._tab.get::<u8>(LevelUpdate::VT_FLAGS, Some(0)).unwrap()
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn side(&self) -> Side {
|
||||||
|
self._tab.get::<Side>(LevelUpdate::VT_SIDE, Some(Side::Buy)).unwrap()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct LevelUpdateArgs {
|
||||||
|
pub price: u64,
|
||||||
|
pub size_: u32,
|
||||||
|
pub flags: u8,
|
||||||
|
pub side: Side,
|
||||||
|
}
|
||||||
|
impl<'a> Default for LevelUpdateArgs {
|
||||||
|
#[inline]
|
||||||
|
fn default() -> Self {
|
||||||
|
LevelUpdateArgs {
|
||||||
|
price: 0,
|
||||||
|
size_: 0,
|
||||||
|
flags: 0,
|
||||||
|
side: Side::Buy,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub struct LevelUpdateBuilder<'a: 'b, 'b> {
|
||||||
|
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||||
|
start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
|
||||||
|
}
|
||||||
|
impl<'a: 'b, 'b> LevelUpdateBuilder<'a, 'b> {
|
||||||
|
#[inline]
|
||||||
|
pub fn add_price(&mut self, price: u64) {
|
||||||
|
self.fbb_.push_slot::<u64>(LevelUpdate::VT_PRICE, price, 0);
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn add_size_(&mut self, size_: u32) {
|
||||||
|
self.fbb_.push_slot::<u32>(LevelUpdate::VT_SIZE_, size_, 0);
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn add_flags(&mut self, flags: u8) {
|
||||||
|
self.fbb_.push_slot::<u8>(LevelUpdate::VT_FLAGS, flags, 0);
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn add_side(&mut self, side: Side) {
|
||||||
|
self.fbb_.push_slot::<Side>(LevelUpdate::VT_SIDE, side, Side::Buy);
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> LevelUpdateBuilder<'a, 'b> {
|
||||||
|
let start = _fbb.start_table();
|
||||||
|
LevelUpdateBuilder {
|
||||||
|
fbb_: _fbb,
|
||||||
|
start_: start,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn finish(self) -> flatbuffers::WIPOffset<LevelUpdate<'a>> {
|
||||||
|
let o = self.fbb_.end_table(self.start_);
|
||||||
|
flatbuffers::WIPOffset::new(o.value())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum MessageOffset {}
|
||||||
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||||
|
|
||||||
|
pub struct Message<'a> {
|
||||||
|
pub _tab: flatbuffers::Table<'a>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> flatbuffers::Follow<'a> for Message<'a> {
|
||||||
|
type Inner = Message<'a>;
|
||||||
|
#[inline]
|
||||||
|
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||||
|
Self {
|
||||||
|
_tab: flatbuffers::Table { buf: buf, loc: loc },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> Message<'a> {
|
||||||
|
#[inline]
|
||||||
|
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||||
|
Message {
|
||||||
|
_tab: table,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[allow(unused_mut)]
|
||||||
|
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||||
|
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||||
|
args: &'args MessageArgs<'args>) -> flatbuffers::WIPOffset<Message<'bldr>> {
|
||||||
|
let mut builder = MessageBuilder::new(_fbb);
|
||||||
|
builder.add_ts_nanos(args.ts_nanos);
|
||||||
|
if let Some(x) = args.body { builder.add_body(x); }
|
||||||
|
if let Some(x) = args.symbol { builder.add_symbol(x); }
|
||||||
|
builder.add_body_type(args.body_type);
|
||||||
|
builder.finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const VT_TS_NANOS: flatbuffers::VOffsetT = 4;
|
||||||
|
pub const VT_SYMBOL: flatbuffers::VOffsetT = 6;
|
||||||
|
pub const VT_BODY_TYPE: flatbuffers::VOffsetT = 8;
|
||||||
|
pub const VT_BODY: flatbuffers::VOffsetT = 10;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn ts_nanos(&self) -> u64 {
|
||||||
|
self._tab.get::<u64>(Message::VT_TS_NANOS, Some(0)).unwrap()
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn symbol(&self) -> Option<&'a str> {
|
||||||
|
self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(Message::VT_SYMBOL, None)
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn body_type(&self) -> MessageBody {
|
||||||
|
self._tab.get::<MessageBody>(Message::VT_BODY_TYPE, Some(MessageBody::NONE)).unwrap()
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn body(&self) -> Option<flatbuffers::Table<'a>> {
|
||||||
|
self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Table<'a>>>(Message::VT_BODY, None)
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
pub fn body_as_trade(&self) -> Option<Trade<'a>> {
|
||||||
|
if self.body_type() == MessageBody::Trade {
|
||||||
|
self.body().map(|u| Trade::init_from_table(u))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
pub fn body_as_level_update(&self) -> Option<LevelUpdate<'a>> {
|
||||||
|
if self.body_type() == MessageBody::LevelUpdate {
|
||||||
|
self.body().map(|u| LevelUpdate::init_from_table(u))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct MessageArgs<'a> {
|
||||||
|
pub ts_nanos: u64,
|
||||||
|
pub symbol: Option<flatbuffers::WIPOffset<&'a str>>,
|
||||||
|
pub body_type: MessageBody,
|
||||||
|
pub body: Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>>,
|
||||||
|
}
|
||||||
|
impl<'a> Default for MessageArgs<'a> {
|
||||||
|
#[inline]
|
||||||
|
fn default() -> Self {
|
||||||
|
MessageArgs {
|
||||||
|
ts_nanos: 0,
|
||||||
|
symbol: None,
|
||||||
|
body_type: MessageBody::NONE,
|
||||||
|
body: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub struct MessageBuilder<'a: 'b, 'b> {
|
||||||
|
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||||
|
start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
|
||||||
|
}
|
||||||
|
impl<'a: 'b, 'b> MessageBuilder<'a, 'b> {
|
||||||
|
#[inline]
|
||||||
|
pub fn add_ts_nanos(&mut self, ts_nanos: u64) {
|
||||||
|
self.fbb_.push_slot::<u64>(Message::VT_TS_NANOS, ts_nanos, 0);
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn add_symbol(&mut self, symbol: flatbuffers::WIPOffset<&'b str>) {
|
||||||
|
self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Message::VT_SYMBOL, symbol);
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn add_body_type(&mut self, body_type: MessageBody) {
|
||||||
|
self.fbb_.push_slot::<MessageBody>(Message::VT_BODY_TYPE, body_type, MessageBody::NONE);
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn add_body(&mut self, body: flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>) {
|
||||||
|
self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Message::VT_BODY, body);
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> MessageBuilder<'a, 'b> {
|
||||||
|
let start = _fbb.start_table();
|
||||||
|
MessageBuilder {
|
||||||
|
fbb_: _fbb,
|
||||||
|
start_: start,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn finish(self) -> flatbuffers::WIPOffset<Message<'a>> {
|
||||||
|
let o = self.fbb_.end_table(self.start_);
|
||||||
|
flatbuffers::WIPOffset::new(o.value())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // pub mod MdShootout
|
||||||
|
|
Loading…
Reference in New Issue
Block a user