Add the service
This commit is contained in:
parent
3e792358ed
commit
45e6ac733e
2 changed files with 41 additions and 5 deletions
15
src/main.rs
15
src/main.rs
|
@ -1,14 +1,19 @@
|
|||
use clap::Parser;
|
||||
use std::process::ExitCode;
|
||||
|
||||
mod address;
|
||||
mod config;
|
||||
mod service;
|
||||
|
||||
const COMMENT_CHAR: char = '#';
|
||||
const DEFAULT_SEPARATOR: char = '+';
|
||||
const KEY_SEPARATOR: char = ':';
|
||||
|
||||
fn main() {
|
||||
let cfg = config::Config::parse();
|
||||
println!("{cfg:?}");
|
||||
println!("{:?}", cfg.addresses());
|
||||
fn main() -> ExitCode {
|
||||
match service::start_service() {
|
||||
Ok(_) => ExitCode::SUCCESS,
|
||||
Err(e) => {
|
||||
eprintln!("{e}");
|
||||
ExitCode::FAILURE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
31
src/service.rs
Normal file
31
src/service.rs
Normal file
|
@ -0,0 +1,31 @@
|
|||
use crate::address::CodedAddress;
|
||||
use crate::config::Config;
|
||||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use std::io;
|
||||
|
||||
pub const BUFF_SIZE: usize = 4096;
|
||||
pub const CONFIG_END: &str = "config|ready\n";
|
||||
|
||||
pub fn start_service() -> Result<()> {
|
||||
let cfg = Config::parse();
|
||||
let mut buffer = String::with_capacity(BUFF_SIZE);
|
||||
let stdin = io::stdin();
|
||||
|
||||
// Handshake
|
||||
loop {
|
||||
buffer.clear();
|
||||
stdin.read_line(&mut buffer)?;
|
||||
if buffer == CONFIG_END {
|
||||
break;
|
||||
}
|
||||
}
|
||||
println!("register|report|smtp‐in|tx‐rcpt");
|
||||
println!("register|ready");
|
||||
|
||||
// Input processing
|
||||
loop {
|
||||
buffer.clear();
|
||||
stdin.read_line(&mut buffer)?;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue