1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use crate::service::hash_service::LsHashService;
use crate::service::validation_code_service::LsValidationCodeService;
use lightspeed_core::error::LsError;
use lightspeed_core::LsCoreModule;
use log::*;
use std::sync::Arc;

pub mod dto;
pub mod service;

#[derive(Clone)]
pub struct LsHashModule {
    pub hash_service: Arc<LsHashService>,
    pub validation_code_service: Arc<LsValidationCodeService>,
}

impl LsHashModule {
    pub fn new(core_module: &LsCoreModule) -> Result<Self, LsError> {
        println!("Creating LsHashModule");
        info!("Creating LsHashModule");

        let hash_service = Arc::new(LsHashService::new());

        let validation_code_service =
            Arc::new(LsValidationCodeService::new(hash_service.clone(), core_module.jwt.clone()));

        Ok(LsHashModule { hash_service, validation_code_service })
    }
}

impl lightspeed_core::module::LsModule for LsHashModule {
    async fn start(&mut self) -> Result<(), LsError> {
        info!("Starting LsHashModule");
        Ok(())
    }
}