1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
//! Connect to a kdb+ service using native rust. //! //! Provides support for kdb+ connectivity using //! uncompressed serialization and deserialization, //! following the [Kx Documentation](https://code.kx.com/q/kb/serialization/). //! //! ## Features //! * Written natively in Rust using stable features only //! * Leverages Rust's type and enum system to match cleanly with the kdb+ type system //! * Outputs `rsq::KObj` to kdb+ readable format i.e. ```(`TSLA;`Q;653.20;200)``` //! * Supports atomic types (0-19h), lists, dictionaries, and tables //! //! ## Drawbacks //! Since `rsq` is written natively in Rust, it is capable of running //! on any stable version of the language. This comes at the cost of //! not using compression/decompression, which is only possible using the //! proprietary Kx provided `c.so`. Therefore, this library is primarily //! for applications where compression is not needed. This would include //! feedhandlers, realtime consumers, etc. as kdb+ only compresses //! [under certain conditions](https://code.kx.com/q/basics/ipc/#compression) //! //! ## Usage //! //! Put this in your `Cargo.toml`: //! //! ```toml //! [dependencies] //! rsq = "0.1" //! ``` //! //! ## Example //! ### Tickerplant Subscriber //! //! The following code will subscribe to a vanilla tickerplant //! for all symbols and print the realtime data to stdout //! using the basic `println!` macro //! //! ```no_run //! use rsq::{Kdb, KObj, KType}; //! let mut kdb = Kdb::new("localhost", 5001, "username", "password"); //! //! kdb.send_async(&KObj::List(vec![ //! KObj::Atom(KType::Symbol(".u.sub".to_string())), //! KObj::Atom(KType::Symbol("trade".to_string())), //! KObj::Atom(KType::Symbol("".to_string())) //! ])).unwrap(); //! //! loop { //! println!("{}",kdb.read()); //! }; //! ``` //! **Output** //! ```bash //! (`upd;`trade;flip (`time;`sym;`price;`size)!((enlist 20:57:00.000);(enlist `TSLA);(enlist 653.1f);(enlist 50j))) //! (`upd;`trade;flip (`time;`sym;`price;`size)!((enlist 20:59:00.000);(enlist `TSLA);(enlist 653.2f);(enlist 30j))) //! (`upd;`trade;flip (`time;`sym;`price;`size)!((enlist 20:59:30.000);(enlist `TSLA);(enlist 653.1f);(enlist 100j))) //! ``` mod header; mod kdb; mod ktype; mod kobj; pub use ktype::KType; pub use kobj::KObj; pub use kdb::Kdb;