initial commit

This commit is contained in:
Sebastian Hugentobler 2022-03-12 16:19:54 +01:00
commit 3d9c98eeca
Signed by: shu
GPG key ID: BB32CF3CA052C2F0
22 changed files with 1075 additions and 0 deletions

19
src/commands/pong.rs Normal file
View file

@ -0,0 +1,19 @@
use std::io::Write;
use std::net::TcpStream;
use std::sync::{Arc, RwLock};
use anyhow::Result;
use crate::bank::Bank;
use crate::commands::Command;
use crate::protocol;
pub struct Pong;
impl Command for Pong {
fn execute(&self, _: Arc<RwLock<Bank>>, _: &[u8], mut stream: &TcpStream) -> Result<usize> {
info!("sending 'pong'");
let written = stream.write(&[protocol::PONG])?;
Ok(written)
}
}