fn req_keys(
    m_state: web::Data<Arc<Mutex<ServerState>>>,
    req: HttpRequest,
    (path, body): (web::Path<(String,)>, web::Bytes),
) -> Result<HttpResponse> {
    // decode protobuf msg containing key, into KeyRequest struct
    let res = pbdec_iter_req(&body);
    if res.is_err() {
        return err_bad_req();
    }
    let in_msg = res.unwrap();

    // lock runtime-live state data
    let state = m_state.lock().unwrap();
    if state.debug {
        println!("{:?}", req);
    }

    // lookup database index by name (path elem 0)
    let idx: usize;
    match state.name_idx.get(&path.0) {
        None => return err_not_found(),
        Some(r_idx) => idx = *r_idx,
    }

    // attempt to list keys, starting at supplied key (or at db-start, if none)
    let mut opts = db::api::IterOptions::new();
    if !in_msg.start_key.is_empty() {
        opts.start(&in_msg.start_key);
    }
    if !in_msg.prefix.is_empty() {
        opts.prefix(&in_msg.prefix);
    }
    let res = state.dbs[idx].db.iter_keys(opts);
    if res.is_err() {
        return err_500();
    }

    // encode protobuf output to bytes
    let key_list = res.unwrap();
    let out_bytes = pbenc_keys_resp(&key_list);

    ok_binary(out_bytes)
}
/// Sequential iteration through all KEYS in db. Start-key in HTTP payload.
Sequential iteration through all KEYS in db. Start-key in HTTP payload.
Sequential iteration through all KEYS in db . Start - key in HTTP payload .
fn req_keys(
    m_state: web::Data<Arc<Mutex<ServerState>>>,
    req: HttpRequest,
    (path, body): (web::Path<(String,)>, web::Bytes),
) -> Result<HttpResponse> {
    // decode protobuf msg containing key, into KeyRequest struct
    let res = pbdec_iter_req(&body);
    if res.is_err() {
        return err_bad_req();
    }
    let in_msg = res.unwrap();
    // lock runtime-live state data
    let state = m_state.lock().unwrap();
    if state.debug {
        println!("{:?}", req);
    }
    // lookup database index by name (path elem 0)
    let idx: usize;
    match state.name_idx.get(&path.0) {
        None => return err_not_found(),
        Some(r_idx) => idx = *r_idx,
    }
    // attempt to list keys, starting at supplied key (or at db-start, if none)
    let mut opts = db::api::IterOptions::new();
    if !in_msg.start_key.is_empty() {
        opts.start(&in_msg.start_key);
    }
    if !in_msg.prefix.is_empty() {
        opts.prefix(&in_msg.prefix);
    }
    let res = state.dbs[idx].db.iter_keys(opts);
    if res.is_err() {
        return err_500();
    }
    // encode protobuf output to bytes
    let key_list = res.unwrap();
    let out_bytes = pbenc_keys_resp(&key_list);
    ok_binary(out_bytes)
}
fn req_keys ( m_state : web :: Data < Arc < Mutex < ServerState > > > , req : HttpRequest , ( path , body ) : ( web :: Path < ( String , ) > , web :: Bytes ) , ) -> Result < HttpResponse > { // decode protobuf msg containing key, into KeyRequest struct let res = pbdec_iter_req ( & body ) ; if res . is_err ( ) { return err_bad_req ( ) ; } let in_msg = res . unwrap ( ) ; // lock runtime-live state data let state = m_state . lock ( ) . unwrap ( ) ; if state . debug { println ! ( " " req ) ; } // lookup database index by name (path elem 0) let idx : usize ; match state . name_idx . get ( & path . 0 ) { None => return err_not_found ( ) , Some ( r_idx ) => idx = * r_idx , } // attempt to list keys, starting at supplied key (or at db-start, if none) let mut opts = db :: api :: IterOptions :: new ( ) ; if ! in_msg . start_key . is_empty ( ) { opts . start ( & in_msg . start_key ) ; } if ! in_msg . prefix . is_empty ( ) { opts . prefix ( & in_msg . prefix ) ; } let res = state . dbs [ idx ] . db . iter_keys ( opts ) ; if res . is_err ( ) { return err_500 ( ) ; } // encode protobuf output to bytes let key_list = res . unwrap ( ) ; let out_bytes = pbenc_keys_resp ( & key_list ) ; ok_binary ( out_bytes ) }
Sequential iteration through all KEYS in db.
Sequential iteration through all KEYS in db .
m_state
web::Data<Arc<Mutex<ServerState>>>
req
(web::Path<(String,)>, web::Bytes)
m_state
web::Data<Arc<Mutex<ServerState>>>
req
(web::Path<(String,)>, web::Bytes)