pub struct Application<'a, C: ApplicationCallback>(/* private fields */);
Expand description
Application callback wrapper.
Implementations§
Source§impl<'a, C> Application<'a, C>where
C: ApplicationCallback + 'static,
impl<'a, C> Application<'a, C>where
C: ApplicationCallback + 'static,
Sourcepub fn try_new(callbacks: &'a C) -> Result<Self, QuickFixError>
pub fn try_new(callbacks: &'a C) -> Result<Self, QuickFixError>
Try create new struct from its underlying components.
Examples found in repository?
examples/demo_config.rs (line 54)
46fn main() -> Result<(), QuickFixError> {
47 println!(">> Configuring application");
48 let settings = build_settings()?;
49
50 println!(">> Creating resources");
51 let store_factory = MemoryMessageStoreFactory::new();
52 let log_factory = LogFactory::try_new(&StdLogger::Stdout)?;
53 let callbacks = MyApplication;
54 let app = Application::try_new(&callbacks)?;
55
56 let mut acceptor = Acceptor::try_new(
57 &settings,
58 &app,
59 &store_factory,
60 &log_factory,
61 FixSocketServerKind::SingleThreaded,
62 )?;
63
64 println!(">> connection handler START");
65 acceptor.start()?;
66
67 println!(">> App running, press 'q' to quit");
68 let mut stdin = stdin().lock();
69 let mut stdin_buf = [0];
70 loop {
71 let _ = stdin.read_exact(&mut stdin_buf);
72 if stdin_buf[0] == b'q' {
73 break;
74 }
75 }
76
77 println!(">> connection handler STOP");
78 acceptor.stop()?;
79
80 println!(">> All cleared. Bye !");
81 Ok(())
82}
More examples
examples/fix_getting_started.rs (line 32)
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 = Acceptor::try_new(
35 &settings,
36 &app,
37 &store_factory,
38 &log_factory,
39 FixSocketServerKind::SingleThreaded,
40 )?;
41
42 println!(">> connection handler START");
43 acceptor.start()?;
44
45 println!(">> App running, press 'q' to quit");
46 let mut stdin = stdin().lock();
47 let mut stdin_buf = [0];
48 loop {
49 let _ = stdin.read_exact(&mut stdin_buf);
50 if stdin_buf[0] == b'q' {
51 break;
52 }
53 }
54
55 println!(">> connection handler STOP");
56 acceptor.stop()?;
57
58 println!(">> All cleared. Bye !");
59 Ok(())
60}
examples/fix_repl/main.rs (line 29)
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(Initiator::try_new(
33 &settings,
34 &app,
35 &store_factory,
36 &log_factory,
37 FixSocketServerKind::SingleThreaded,
38 )?),
39 "acceptor" => server_loop(Acceptor::try_new(
40 &settings,
41 &app,
42 &store_factory,
43 &log_factory,
44 FixSocketServerKind::SingleThreaded,
45 )?),
46 _ => {
47 eprintln!("Invalid connection mode");
48 exit(1);
49 }
50 }?;
51
52 println!(">> All cleared. Bye !");
53 Ok(())
54}
Trait Implementations§
Source§impl<'a, C: Debug + ApplicationCallback> Debug for Application<'a, C>
impl<'a, C: Debug + ApplicationCallback> Debug for Application<'a, C>
Source§impl<C: ApplicationCallback> Drop for Application<'_, C>
impl<C: ApplicationCallback> Drop for Application<'_, C>
Auto Trait Implementations§
impl<'a, C> Freeze for Application<'a, C>
impl<'a, C> RefUnwindSafe for Application<'a, C>where
C: RefUnwindSafe,
impl<'a, C> !Send for Application<'a, C>
impl<'a, C> !Sync for Application<'a, C>
impl<'a, C> Unpin for Application<'a, C>
impl<'a, C> UnwindSafe for Application<'a, C>where
C: RefUnwindSafe,
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