40 lines
942 B
Rust
40 lines
942 B
Rust
use std::sync::mpsc::{Receiver, Sender};
|
|
use crate::store::TicketStore;
|
|
|
|
pub mod data;
|
|
pub mod store;
|
|
|
|
// Refer to the tests to understand the expected schema.
|
|
pub enum Command {
|
|
Insert { todo!() },
|
|
Get { todo!() }
|
|
}
|
|
|
|
pub fn launch() -> Sender<Command> {
|
|
let (sender, receiver) = std::sync::mpsc::channel();
|
|
std::thread::spawn(move || server(receiver));
|
|
sender
|
|
}
|
|
|
|
// TODO: handle incoming commands as expected.
|
|
pub fn server(receiver: Receiver<Command>) {
|
|
let mut store = TicketStore::new();
|
|
loop {
|
|
match receiver.recv() {
|
|
Ok(Command::Insert {}) => {
|
|
todo!()
|
|
}
|
|
Ok(Command::Get {
|
|
todo!()
|
|
}) => {
|
|
todo!()
|
|
}
|
|
Err(_) => {
|
|
// There are no more senders, so we can safely break
|
|
// and shut down the server.
|
|
break
|
|
},
|
|
}
|
|
}
|
|
}
|