fixer 0.11.0

A full featured messaging engine for the FIX protocol implemented in Rust
Documentation
use crate::log::{LogEnum, LogFactoryEnum, LogFactoryTrait, LogTrait};
use crate::session::session_id::SessionID;
use rustc_hash::FxHashMap;
use std::sync::Arc;

#[derive(Default)]
pub struct NullLog;

impl LogTrait for NullLog {
    async fn on_incoming(&mut self, _data: &[u8]) {}
    async fn on_outgoing(&mut self, _data: &[u8]) {}
    async fn on_event(&mut self, _data: &str) {}
    async fn on_eventf(&mut self, _format: &str, _params: FxHashMap<String, String>) {}
}

#[derive(Clone)]
pub struct NullLogFactory;

impl NullLogFactory {
    // new creates an instance of LogFactory that returns no-op loggers.
    #[allow(clippy::new_ret_no_self)]
    pub fn new() -> LogFactoryEnum {
        LogFactoryEnum::NullLogFactory(NullLogFactory)
    }
}

impl LogFactoryTrait for NullLogFactory {
    async fn create(&mut self) -> Result<LogEnum, String> {
        Ok(LogEnum::NullLog(NullLog))
    }

    async fn create_session_log(&mut self, _session_id: Arc<SessionID>) -> Result<LogEnum, String> {
        Ok(LogEnum::NullLog(NullLog))
    }
}