config.rs 844 B

12345678910111213141516171819202122232425262728293031323334353637
  1. use serde::{Deserialize, Serialize};
  2. use std::sync::OnceLock;
  3. //全局配置
  4. pub static EMU_CONFIG: OnceLock<AppConfig> = OnceLock::new();
  5. #[derive(Debug, Serialize, Deserialize)]
  6. pub struct AppConfig {
  7. pub emu: EmuConfig,
  8. pub rabbitmq: RabbitMQConfig,
  9. }
  10. #[derive(Serialize, Deserialize, Debug)]
  11. pub struct EmuConfig {
  12. pub ver: String,
  13. pub pcs: PcsConfig,
  14. pub ems: EmsConfig,
  15. pub bms: BmsConfig,
  16. }
  17. #[derive(Serialize, Deserialize, Debug)]
  18. pub struct PcsConfig {}
  19. #[derive(Serialize, Deserialize, Debug)]
  20. pub struct EmsConfig {
  21. //读取间隔, 单位ms
  22. pub read_interval: u64,
  23. }
  24. #[derive(Serialize, Deserialize, Debug)]
  25. pub struct BmsConfig {}
  26. #[derive(Serialize, Deserialize, Debug)]
  27. pub struct RabbitMQConfig {
  28. pub host: String,
  29. pub port: u16,
  30. pub username: String,
  31. pub password: String,
  32. }