SHARE
TWEET

Untitled

a guest Aug 14th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. use serde::Deserialize;
  2. use serde_urlencoded; // 0.5.5
  3. use std::collections::HashMap;
  4.  
  5. #[derive(Deserialize, Debug)]
  6. pub struct PagedRequest {
  7.     pub per_page: Option<usize>,
  8.     pub page: Option<usize>,
  9. }
  10.  
  11.  
  12. #[derive(Deserialize, Debug)]
  13. pub struct FilteredRequest {
  14.     #[serde(flatten)]
  15.     pagination: PagedRequest,
  16.     #[serde(flatten)]
  17.     filters: HashMap<String, Option<String>>,
  18. }
  19.  
  20. fn main() {
  21.     let _result = dbg!(serde_urlencoded::from_str::<FilteredRequest>("?page=1"));
  22.  
  23. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top