pub struct SessionSettings(/* private fields */);
Expand description
Container for setting dictionaries mapped to sessions.
Implementations§
Source§impl SessionSettings
impl SessionSettings
Sourcepub fn new() -> Self
pub fn new() -> Self
Create new empty struct.
Examples found in repository?
examples/demo_config.rs (line 21)
20fn build_settings() -> Result<SessionSettings, QuickFixError> {
21 let mut settings = SessionSettings::new();
22
23 settings.set(
24 None,
25 Dictionary::try_from_items(&[
26 &ConnectionType::Acceptor,
27 &ReconnectInterval(60),
28 &FileStorePath("store"),
29 ])?,
30 )?;
31
32 settings.set(
33 Some(&SessionId::try_new("FIX.4.4", "ME", "THEIR", "")?),
34 Dictionary::try_from_items(&[
35 &StartTime("12:30:00"),
36 &EndTime("23:30:00"),
37 &HeartBtInt(20),
38 &SocketAcceptPort(4000),
39 &DataDictionary("quickfix-ffi/libquickfix/spec/FIX41.xml"),
40 ])?,
41 )?;
42
43 Ok(settings)
44}
Sourcepub fn try_from_path<P: AsRef<Path>>(path: P) -> Result<Self, QuickFixError>
pub fn try_from_path<P: AsRef<Path>>(path: P) -> Result<Self, QuickFixError>
Try to load struct data from Path.
Examples found in repository?
examples/fix_getting_started.rs (line 28)
20fn main() -> Result<(), QuickFixError> {
21 let args: Vec<_> = env::args().collect();
22 let Some(config_file) = args.get(1) else {
23 eprintln!("Bad program usage: {} <config_file>", args[0]);
24 exit(1);
25 };
26
27 println!(">> Creating resources");
28 let settings = SessionSettings::try_from_path(config_file)?;
29 let store_factory = FileMessageStoreFactory::try_new(&settings)?;
30 let log_factory = LogFactory::try_new(&StdLogger::Stdout)?;
31 let callbacks = MyApplication;
32 let app = Application::try_new(&callbacks)?;
33
34 let mut acceptor = SocketAcceptor::try_new(&settings, &app, &store_factory, &log_factory)?;
35
36 println!(">> connection handler START");
37 acceptor.start()?;
38
39 println!(">> App running, press 'q' to quit");
40 let mut stdin = stdin().lock();
41 let mut stdin_buf = [0];
42 loop {
43 let _ = stdin.read_exact(&mut stdin_buf);
44 if stdin_buf[0] == b'q' {
45 break;
46 }
47 }
48
49 println!(">> connection handler STOP");
50 acceptor.stop()?;
51
52 println!(">> All cleared. Bye !");
53 Ok(())
54}
More examples
examples/fix_repl/main.rs (line 25)
14fn main() -> Result<(), QuickFixError> {
15 let args: Vec<_> = env::args().collect();
16 let (Some(connect_mode), Some(config_file)) = (args.get(1), args.get(2)) else {
17 eprintln!(
18 "Bad program usage: {} [acceptor|initiator] <config_file>",
19 args[0]
20 );
21 exit(1);
22 };
23
24 println!(">> Creating resources");
25 let settings = SessionSettings::try_from_path(config_file)?;
26 let store_factory = FileMessageStoreFactory::try_new(&settings)?;
27 let log_factory = LogFactory::try_new(&StdLogger::Stdout)?;
28 let callbacks = MyApplication::new();
29 let app = Application::try_new(&callbacks)?;
30
31 match connect_mode.as_str() {
32 "initiator" => server_loop(SocketInitiator::try_new(
33 &settings,
34 &app,
35 &store_factory,
36 &log_factory,
37 )?),
38 "acceptor" => server_loop(SocketAcceptor::try_new(
39 &settings,
40 &app,
41 &store_factory,
42 &log_factory,
43 )?),
44 _ => {
45 eprintln!("Invalid connection mode");
46 exit(1);
47 }
48 }?;
49
50 println!(">> All cleared. Bye !");
51 Ok(())
52}
Sourcepub fn with_dictionary<T, F>(
&self,
session_id: Option<&SessionId>,
f: F,
) -> Option<T>where
F: FnOnce(&Dictionary) -> T,
pub fn with_dictionary<T, F>(
&self,
session_id: Option<&SessionId>,
f: F,
) -> Option<T>where
F: FnOnce(&Dictionary) -> T,
Borrow inner dictionary for session or global configuration.
Sourcepub fn set(
&mut self,
session_id: Option<&SessionId>,
value: Dictionary,
) -> Result<(), QuickFixError>
pub fn set( &mut self, session_id: Option<&SessionId>, value: Dictionary, ) -> Result<(), QuickFixError>
Set dictionary parameter for session or global configuration.
Examples found in repository?
examples/demo_config.rs (lines 23-30)
20fn build_settings() -> Result<SessionSettings, QuickFixError> {
21 let mut settings = SessionSettings::new();
22
23 settings.set(
24 None,
25 Dictionary::try_from_items(&[
26 &ConnectionType::Acceptor,
27 &ReconnectInterval(60),
28 &FileStorePath("store"),
29 ])?,
30 )?;
31
32 settings.set(
33 Some(&SessionId::try_new("FIX.4.4", "ME", "THEIR", "")?),
34 Dictionary::try_from_items(&[
35 &StartTime("12:30:00"),
36 &EndTime("23:30:00"),
37 &HeartBtInt(20),
38 &SocketAcceptPort(4000),
39 &DataDictionary("quickfix-ffi/libquickfix/spec/FIX41.xml"),
40 ])?,
41 )?;
42
43 Ok(settings)
44}
Trait Implementations§
Source§impl Debug for SessionSettings
impl Debug for SessionSettings
Source§impl Default for SessionSettings
impl Default for SessionSettings
Auto Trait Implementations§
impl Freeze for SessionSettings
impl RefUnwindSafe for SessionSettings
impl !Send for SessionSettings
impl !Sync for SessionSettings
impl Unpin for SessionSettings
impl UnwindSafe for SessionSettings
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