Function edjx::kv::get

source ·
pub fn get<S>(key: S) -> Result<Vec<u8>, KVError>where
    S: AsRef<str>,
Expand description

Returns the value associated with the provided key.

Example

let some_key = "some_key".to_owned();

let value = match kv::get(&some_key) {
    Err(e) => {
        let status = match e {
            KVError::Unknown => StatusCode::BAD_REQUEST,
            KVError::UnAuthorized => StatusCode::UNAUTHORIZED,
            KVError::NotFound  => StatusCode::NOT_FOUND,
        };
        return HttpResponse::from(e.to_string()).set_status(status);
    }
    Ok(val) => val,
};