pub fn list(req: &mut Request) -> IronResult<Response> {
    let lcr = match req.get::<::bodyparser::Struct<ListCompletionsRequest>>() {
        Ok(Some(s)) => {
            trace!("parsed ListCompletionsRequest");
            s
        },
        Ok(None) => {
            trace!("failed parsing ListCompletionsRequest");
            return Ok(Response::with(status::BadRequest))
        },
        Err(err) => {
            trace!("error while parsing ListCompletionsRequest");
            return Err(IronError::new(err, status::InternalServerError))
        }
    };

    let mutex = req.get::<::persistent::Write<EngineProvider>>().unwrap();
    let engine = mutex.lock().unwrap();
    match engine.list_completions(&lcr.context()) {
        // 200 OK; found the definition
        Ok(Some(completions)) => {
            trace!("got a match");
            let res = completions.into_iter().map(|c| CompletionResponse::from(c)).collect::<Vec<_>>();
            let content_type = "application/json".parse::<Mime>().unwrap();
            Ok(Response::with((content_type, status::Ok, json::encode(&res).unwrap())))
        },

        // 204 No Content; Everything went ok, but the definition was not found.
        Ok(None) => {
            trace!("did not find any match");
            Ok(Response::with(status::NoContent))
        },

        // 500 Internal Server Error; Error occurred while searching for the definition
        Err(err) => {
            trace!("encountered an error");
            Err(IronError::new(err, status::InternalServerError))
        }
    }
}
/// Given a location, return a list of possible completions
Given a location, return a list of possible completions
Given a location return a list of possible completions
pub fn list(req: &mut Request) -> IronResult<Response> {
    let lcr = match req.get::<::bodyparser::Struct<ListCompletionsRequest>>() {
        Ok(Some(s)) => {
            trace!("parsed ListCompletionsRequest");
            s
        },
        Ok(None) => {
            trace!("failed parsing ListCompletionsRequest");
            return Ok(Response::with(status::BadRequest))
        },
        Err(err) => {
            trace!("error while parsing ListCompletionsRequest");
            return Err(IronError::new(err, status::InternalServerError))
        }
    };
    let mutex = req.get::<::persistent::Write<EngineProvider>>().unwrap();
    let engine = mutex.lock().unwrap();
    match engine.list_completions(&lcr.context()) {
        // 200 OK; found the definition
        Ok(Some(completions)) => {
            trace!("got a match");
            let res = completions.into_iter().map(|c| CompletionResponse::from(c)).collect::<Vec<_>>();
            let content_type = "application/json".parse::<Mime>().unwrap();
            Ok(Response::with((content_type, status::Ok, json::encode(&res).unwrap())))
        },
        // 204 No Content; Everything went ok, but the definition was not found.
        Ok(None) => {
            trace!("did not find any match");
            Ok(Response::with(status::NoContent))
        },
        // 500 Internal Server Error; Error occurred while searching for the definition
        Err(err) => {
            trace!("encountered an error");
            Err(IronError::new(err, status::InternalServerError))
        }
    }
}
pub fn list ( req : & mut Request ) -> IronResult < Response > { let lcr = match req . get :: < :: bodyparser :: Struct < ListCompletionsRequest > > ( ) { Ok ( Some ( s ) ) => { trace ! ( " " ) ; s } , Ok ( None ) => { trace ! ( " " ) ; return Ok ( Response :: with ( status :: BadRequest ) ) } , Err ( err ) => { trace ! ( " " ) ; return Err ( IronError :: new ( err , status :: InternalServerError ) ) } } ; let mutex = req . get :: < :: persistent :: Write < EngineProvider > > ( ) . unwrap ( ) ; let engine = mutex . lock ( ) . unwrap ( ) ; match engine . list_completions ( & lcr . context ( ) ) { // 200 OK; found the definition Ok ( Some ( completions ) ) => { trace ! ( " " ) ; let res = completions . into_iter ( ) . map ( | c | CompletionResponse :: from ( c ) ) . collect :: < Vec < _ > > ( ) ; let content_type = " " . parse :: < Mime > ( ) . unwrap ( ) ; Ok ( Response :: with ( ( content_type , status :: Ok , json :: encode ( & res ) . unwrap ( ) ) ) ) } , // 204 No Content; Everything went ok, but the definition was not found. Ok ( None ) => { trace ! ( " " ) ; Ok ( Response :: with ( status :: NoContent ) ) } , // 500 Internal Server Error; Error occurred while searching for the definition Err ( err ) => { trace ! ( " " ) ; Err ( IronError :: new ( err , status :: InternalServerError ) ) } } }
Given a location, return a list of possible completions
Given a location return a list of possible completions
req
&mut Request
req
&mut Request