#![warn(missing_docs, missing_debug_implementations)]
mod acceptor;
mod application;
mod data_dictionary;
mod days;
mod dictionary;
pub mod dictionary_item;
mod error;
mod group;
mod header;
mod initiator;
mod log_factory;
mod message;
mod message_store_factory;
mod session;
mod session_id;
mod session_settings;
mod trailer;
mod utils;
use std::ffi::{CString, NulError};
pub use acceptor::Acceptor;
pub use application::{
Application, ApplicationCallback, MsgFromAdminError, MsgFromAppError, MsgToAppError,
};
pub use data_dictionary::DataDictionary;
pub use days::DayOfWeek;
pub use dictionary::Dictionary;
pub use error::QuickFixError;
pub use group::Group;
pub use header::Header;
pub use initiator::Initiator;
pub use log_factory::{LogCallback, LogFactory, NullLogger, StdLogger};
pub use message::Message;
pub use message_store_factory::{
FfiMessageStoreFactory, FileMessageStoreFactory, MemoryMessageStoreFactory,
NullMessageStoreFactory,
};
pub use session::{send_to_target, Session};
pub use session_id::SessionId;
pub use session_settings::SessionSettings;
pub use trailer::Trailer;
#[cfg(feature = "log")]
pub use log_factory::RustLogger;
#[cfg(feature = "build-with-mysql")]
pub use message_store_factory::mysql::MySqlMessageStoreFactory;
#[cfg(feature = "build-with-postgres")]
pub use message_store_factory::postgres::PostgresMessageStoreFactory;
pub trait ConnectionHandler {
fn start(&mut self) -> Result<(), QuickFixError>;
fn block(&mut self) -> Result<(), QuickFixError>;
fn poll(&mut self) -> Result<bool, QuickFixError>;
fn stop(&mut self) -> Result<(), QuickFixError>;
fn is_logged_on(&self) -> Result<bool, QuickFixError>;
fn is_stopped(&self) -> Result<bool, QuickFixError>;
}
pub trait SessionContainer {
fn session(&self, session_id: SessionId) -> Result<Session<'_>, QuickFixError>;
}
pub trait IntoFixValue {
fn into_fix_value(self) -> Result<CString, NulError>;
}
macro_rules! impl_into_fix_value {
($t:ty) => {
impl IntoFixValue for $t {
fn into_fix_value(self) -> Result<CString, NulError> {
CString::new(self.to_string())
}
}
};
}
impl_into_fix_value!(u8);
impl_into_fix_value!(u16);
impl_into_fix_value!(u32);
impl_into_fix_value!(u64);
impl_into_fix_value!(u128);
impl_into_fix_value!(usize);
impl_into_fix_value!(i8);
impl_into_fix_value!(i16);
impl_into_fix_value!(i32);
impl_into_fix_value!(i64);
impl_into_fix_value!(i128);
impl_into_fix_value!(isize);
impl_into_fix_value!(f32);
impl_into_fix_value!(f64);
impl IntoFixValue for String {
fn into_fix_value(self) -> Result<CString, NulError> {
CString::new(self)
}
}
impl IntoFixValue for &str {
fn into_fix_value(self) -> Result<CString, NulError> {
CString::new(self)
}
}
impl IntoFixValue for bool {
fn into_fix_value(self) -> Result<CString, NulError> {
CString::new(if self { "Y" } else { "N" })
}
}
pub trait FieldMap {
fn get_field(&self, tag: i32) -> Option<String>;
fn set_field<V: IntoFixValue>(&mut self, tag: i32, value: V) -> Result<(), QuickFixError>;
fn remove_field(&mut self, tag: i32) -> Result<(), QuickFixError>;
fn add_group(&mut self, group: &Group) -> Result<(), QuickFixError>;
fn clone_group(&self, index: i32, tag: i32) -> Option<Group>;
}
pub trait ForeignPropertyGetter<T> {
fn ffi_get(&self, key: CString) -> Result<T, QuickFixError>;
}
pub trait ForeignPropertySetter<T> {
fn ffi_set(&mut self, key: CString, value: T) -> Result<(), QuickFixError>;
}
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
#[non_exhaustive]
pub enum FixSocketServerKind {
#[default]
SingleThreaded,
MultiThreaded,
#[cfg(feature = "build-with-ssl")]
SslSingleThreaded,
#[cfg(feature = "build-with-ssl")]
SslMultiThreaded,
}
impl FixSocketServerKind {
fn is_single_threaded(self) -> bool {
match self {
Self::SingleThreaded => true,
Self::MultiThreaded => false,
#[cfg(feature = "build-with-ssl")]
Self::SslSingleThreaded => true,
#[cfg(feature = "build-with-ssl")]
Self::SslMultiThreaded => false,
}
}
fn is_ssl_enabled(self) -> bool {
match self {
Self::SingleThreaded => false,
Self::MultiThreaded => false,
#[cfg(feature = "build-with-ssl")]
Self::SslSingleThreaded => true,
#[cfg(feature = "build-with-ssl")]
Self::SslMultiThreaded => true,
}
}
}