fn cpu_new<'a>(req: &mut Request, response: Response<'a>) -> MiddlewareResult<'a> {
	match req.extensions().get::<CpuDb>() {
		Some(cpuserv) => {
			let mut w_cpuserv = cpuserv.write().unwrap();
			let cpu_no = w_cpuserv.next_cpu;

			let client = CpuClient {
				state: P150Cpu::new(),
				last:  P150Cpu::new(),
			};

			w_cpuserv.database.insert(cpu_no, client);
			w_cpuserv.next_cpu += 1;

			response.send(json::encode(&cpu_no).ok().unwrap())
		},
		None => { response.send("did not find cpu serv") }
	}
}
/// POST /cpu/new: creates a new CPU and adds it to the CpuServ with the next
/// available ID number.
POST /cpu/new: creates a new CPU and adds it to the CpuServ with the next
available ID number.
POST / cpu / new : creates a new CPU and adds it to the CpuServ with the next available ID number .
fn cpu_new<'a>(req: &mut Request, response: Response<'a>) -> MiddlewareResult<'a> {
	match req.extensions().get::<CpuDb>() {
		Some(cpuserv) => {
			let mut w_cpuserv = cpuserv.write().unwrap();
			let cpu_no = w_cpuserv.next_cpu;
			let client = CpuClient {
				state: P150Cpu::new(),
				last:  P150Cpu::new(),
			};
			w_cpuserv.database.insert(cpu_no, client);
			w_cpuserv.next_cpu += 1;
			response.send(json::encode(&cpu_no).ok().unwrap())
		},
		None => { response.send("did not find cpu serv") }
	}
}
fn cpu_new < ' a > ( req : & mut Request , response : Response < ' a > ) -> MiddlewareResult < ' a > { match req . extensions ( ) . get :: < CpuDb > ( ) { Some ( cpuserv ) => { let mut w_cpuserv = cpuserv . write ( ) . unwrap ( ) ; let cpu_no = w_cpuserv . next_cpu ; let client = CpuClient { state : P150Cpu :: new ( ) , last : P150Cpu :: new ( ) , } ; w_cpuserv . database . insert ( cpu_no , client ) ; w_cpuserv . next_cpu += 1 ; response . send ( json :: encode ( & cpu_no ) . ok ( ) . unwrap ( ) ) } , None => { response . send ( " " ) } } }
POST /cpu/new: creates a new CPU and adds it to the CpuServ with the next
available ID number.
POST / cpu / new : creates a new CPU and adds it to the CpuServ with the next available ID number .
req
&mut Request
response
Response<'a>