fn stat_wrapper(f: fn(TcpStream, ServerFiles, Arc<ServerStats>) -> Option<(u32, String)>, stream: TcpStream, server_files: ServerFiles, stats: Arc<ServerStats>) -> Option<RequestResult> {
    let date = Utc::now().naive_local();
    let start = Instant::now();
    let connection_result = f(stream, server_files, stats);
    let duration = start.elapsed().as_millis();

    match connection_result {
        Some(res) => Some(RequestResult { response_code: res.0, duration: duration, time: date, requested_resource: res.1}),
        None => None
    }
}
/// Wraps the functionality to handle the request to retrieve its stats
Wraps the functionality to handle the request to retrieve its stats
Wraps the functionality to handle the request to retrieve its stats
fn stat_wrapper(f: fn(TcpStream, ServerFiles, Arc<ServerStats>) -> Option<(u32, String)>, stream: TcpStream, server_files: ServerFiles, stats: Arc<ServerStats>) -> Option<RequestResult> {
    let date = Utc::now().naive_local();
    let start = Instant::now();
    let connection_result = f(stream, server_files, stats);
    let duration = start.elapsed().as_millis();
    match connection_result {
        Some(res) => Some(RequestResult { response_code: res.0, duration: duration, time: date, requested_resource: res.1}),
        None => None
    }
}
fn stat_wrapper ( f : fn ( TcpStream , ServerFiles , Arc < ServerStats > ) -> Option < ( u32 , String ) > , stream : TcpStream , server_files : ServerFiles , stats : Arc < ServerStats > ) -> Option < RequestResult > { let date = Utc :: now ( ) . naive_local ( ) ; let start = Instant :: now ( ) ; let connection_result = f ( stream , server_files , stats ) ; let duration = start . elapsed ( ) . as_millis ( ) ; match connection_result { Some ( res ) => Some ( RequestResult { response_code : res . 0 , duration : duration , time : date , requested_resource : res . 1 } ) , None => None } }
Wraps the functionality to handle the request to retrieve its stats
Wraps the functionality to handle the request to retrieve its stats
f
fn(TcpStream, ServerFiles, Arc<ServerStats>) -> Option<(u32, String)>
stream
TcpStream
server_files
ServerFiles
stats
Arc<ServerStats>
f
fn(TcpStream, ServerFiles, Arc<ServerStats>) -> Option<(u32, String)>
stream
TcpStream
server_files
ServerFiles
stats
Arc<ServerStats>