Skip to content

Commit

Permalink
πŸ“ Add code sample to rustdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurlm committed Nov 30, 2023
1 parent 70394dc commit 4d87926
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ You may consider checking out this [directory](./quickfix/examples/) for more ex
Yes. But keep in mind that not every feature of the original FIX library are available.
If some of your needs are missing: PR / feedbacks are welcomed 😁!

Crate is not published (yet), because it is still in the review process.
Crate is not published (yet), because it is still in the [reviewing process](https://github.com/quickfix/quickfix/issues/533).
If you want to use it in your project, just add this to your `Cargo.toml` config file:

```toml
Expand Down
55 changes: 55 additions & 0 deletions quickfix/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,61 @@ Following package must be install to build the library:
- a C++ compiler (with C++17 support)
- `rustup` / `rustc` / `cargo` (obviously πŸ˜‰)
## Example usage
Here some minimal code sample to getting started:
```rust
# use quickfix::*;
// Configure FIX engine.
let mut settings = SessionSettings::new();
settings.set(None, {
let mut params = Dictionary::default();
params.set("ConnectionType", "acceptor".to_string())?;
params
})?;
settings.set(Some(SessionId::try_new("FIX.4.4", "ME", "THEIR", "")?), {
let mut params = Dictionary::default();
params.set("StartTime", "12:30:00".to_string())?;
params.set("EndTime", "23:30:00".to_string())?;
params.set("SocketAcceptPort", 4000)?;
params.set("DataDictionary", "../quickfix-ffi/libquickfix/spec/FIX41.xml".to_string())?;
params
})?;
// Configure FIX callbacks.
pub struct MyApplication;
impl ApplicationCallback for MyApplication {
// Implement whatever callback you need
fn on_create(&self, _session: &SessionId) {
// Do whatever you want here 😁
}
}
// Create FIX objects.
let store_factory = MemoryMessageStoreFactory::new();
let log_factory = LogFactory::try_new(&StdLogger::Stdout)?;
let app = Application::try_new(&MyApplication)?;
let mut acceptor = SocketAcceptor::try_new(&settings, &app, &store_factory, &log_factory)?;
// Start session.
acceptor.start()?;
loop {
// Do whatever you want here ...
# break;
}
// End application
acceptor.stop()?;
# Ok::<(), QuickFixError>(())
```
*/

mod application;
Expand Down

0 comments on commit 4d87926

Please sign in to comment.