pub struct QueryBuilder { /* private fields */ }Expand description
Utility builder for building query::Query.
Implementations§
Source§impl QueryBuilder
An implementation for QueryBuilder.
There are two function types:
impl QueryBuilder
An implementation for QueryBuilder. There are two function types:
- functions that can accept a single argument.
- functions that can accept a
Vectype argument.
The former ones simply add the accepted value to this builder, but the latter ones always replace the value in placed in this builder by the accepted one.
Sourcepub fn begin() -> Self
pub fn begin() -> Self
Initializes QueryBuilder.
Examples found in repository?
examples/get_single_event.rs (line 6)
4async fn main() {
5 // fetch https://rust.connpass.com/event/228732/
6 let query = QueryBuilder::begin().event_id(228732).build();
7 if let Ok(query) = query {
8 let client = ConnpassClient::new();
9 let res = client.send_request(query).await;
10 match res {
11 Ok(r) => println!("{:?}", r),
12 Err(err) => eprintln!("{:?}", err),
13 }
14 }
15}More examples
examples/get_events_with_various_queries.rs (line 8)
7async fn main() {
8 let query = QueryBuilder::begin()
9 // You can build query parameters by functions that accept a single argument,
10 .keyword_or("Python")
11 .keyword_or("機械学習")
12 // or can do by functions that accept a `Vec` argument.
13 .yms(vec![202110, 202111])
14 .order(OrderOption::Newer)
15 .count(15)
16 .build();
17 if let Ok(query) = query {
18 let client = ConnpassClient::new();
19 let res = client.send_request(query).await;
20 match res {
21 Ok(r) => println!("{:?}", r),
22 Err(err) => eprintln!("{:?}", err),
23 }
24 }
25}pub fn event_ids(self, ids: Vec<u32>) -> Self
Sourcepub fn event_id(self, id: u32) -> Self
pub fn event_id(self, id: u32) -> Self
Examples found in repository?
examples/get_single_event.rs (line 6)
4async fn main() {
5 // fetch https://rust.connpass.com/event/228732/
6 let query = QueryBuilder::begin().event_id(228732).build();
7 if let Ok(query) = query {
8 let client = ConnpassClient::new();
9 let res = client.send_request(query).await;
10 match res {
11 Ok(r) => println!("{:?}", r),
12 Err(err) => eprintln!("{:?}", err),
13 }
14 }
15}pub fn keywords(self, keywords: Vec<String>) -> Self
pub fn keyword(self, keyword: impl Into<String>) -> Self
pub fn keywords_or(self, keywords: Vec<String>) -> Self
Sourcepub fn keyword_or(self, keyword: impl Into<String>) -> Self
pub fn keyword_or(self, keyword: impl Into<String>) -> Self
Examples found in repository?
examples/get_events_with_various_queries.rs (line 10)
7async fn main() {
8 let query = QueryBuilder::begin()
9 // You can build query parameters by functions that accept a single argument,
10 .keyword_or("Python")
11 .keyword_or("機械学習")
12 // or can do by functions that accept a `Vec` argument.
13 .yms(vec![202110, 202111])
14 .order(OrderOption::Newer)
15 .count(15)
16 .build();
17 if let Ok(query) = query {
18 let client = ConnpassClient::new();
19 let res = client.send_request(query).await;
20 match res {
21 Ok(r) => println!("{:?}", r),
22 Err(err) => eprintln!("{:?}", err),
23 }
24 }
25}Sourcepub fn yms(self, ym: Vec<u32>) -> Self
pub fn yms(self, ym: Vec<u32>) -> Self
Examples found in repository?
examples/get_events_with_various_queries.rs (line 13)
7async fn main() {
8 let query = QueryBuilder::begin()
9 // You can build query parameters by functions that accept a single argument,
10 .keyword_or("Python")
11 .keyword_or("機械学習")
12 // or can do by functions that accept a `Vec` argument.
13 .yms(vec![202110, 202111])
14 .order(OrderOption::Newer)
15 .count(15)
16 .build();
17 if let Ok(query) = query {
18 let client = ConnpassClient::new();
19 let res = client.send_request(query).await;
20 match res {
21 Ok(r) => println!("{:?}", r),
22 Err(err) => eprintln!("{:?}", err),
23 }
24 }
25}pub fn ym(self, ym: u32) -> Self
pub fn ymds(self, ymd: Vec<u32>) -> Self
pub fn ymd(self, ymd: u32) -> Self
pub fn nicknames(self, nickname: Vec<String>) -> Self
pub fn nickname(self, nickname: impl Into<String>) -> Self
pub fn owner_nicknames(self, owner_nickname: Vec<String>) -> Self
pub fn owner_nickname(self, owner_nickname: impl Into<String>) -> Self
pub fn series_ids(self, series_ids: Vec<u32>) -> Self
pub fn series_id(self, series_id: u32) -> Self
pub fn start(self, start: u32) -> Self
Sourcepub fn order(self, order: OrderOption) -> Self
pub fn order(self, order: OrderOption) -> Self
Examples found in repository?
examples/get_events_with_various_queries.rs (line 14)
7async fn main() {
8 let query = QueryBuilder::begin()
9 // You can build query parameters by functions that accept a single argument,
10 .keyword_or("Python")
11 .keyword_or("機械学習")
12 // or can do by functions that accept a `Vec` argument.
13 .yms(vec![202110, 202111])
14 .order(OrderOption::Newer)
15 .count(15)
16 .build();
17 if let Ok(query) = query {
18 let client = ConnpassClient::new();
19 let res = client.send_request(query).await;
20 match res {
21 Ok(r) => println!("{:?}", r),
22 Err(err) => eprintln!("{:?}", err),
23 }
24 }
25}Sourcepub fn count(self, count: u8) -> Self
pub fn count(self, count: u8) -> Self
Examples found in repository?
examples/get_events_with_various_queries.rs (line 15)
7async fn main() {
8 let query = QueryBuilder::begin()
9 // You can build query parameters by functions that accept a single argument,
10 .keyword_or("Python")
11 .keyword_or("機械学習")
12 // or can do by functions that accept a `Vec` argument.
13 .yms(vec![202110, 202111])
14 .order(OrderOption::Newer)
15 .count(15)
16 .build();
17 if let Ok(query) = query {
18 let client = ConnpassClient::new();
19 let res = client.send_request(query).await;
20 match res {
21 Ok(r) => println!("{:?}", r),
22 Err(err) => eprintln!("{:?}", err),
23 }
24 }
25}pub fn format(self, format: impl Into<String>) -> Self
Sourcepub fn build(self) -> Result<Query, ConnpassCliError>
pub fn build(self) -> Result<Query, ConnpassCliError>
Converts from QueryBuilder to Query with some validation checks.
The following checks run in this function:
- validate the
countvalue in range of 0 to 100. - validate if the
formatvalue is just “json”.
These validation specifications are described in connpass’s documentation. Please have a look at https://connpass.com/about/api/.
Examples found in repository?
examples/get_single_event.rs (line 6)
4async fn main() {
5 // fetch https://rust.connpass.com/event/228732/
6 let query = QueryBuilder::begin().event_id(228732).build();
7 if let Ok(query) = query {
8 let client = ConnpassClient::new();
9 let res = client.send_request(query).await;
10 match res {
11 Ok(r) => println!("{:?}", r),
12 Err(err) => eprintln!("{:?}", err),
13 }
14 }
15}More examples
examples/get_events_with_various_queries.rs (line 16)
7async fn main() {
8 let query = QueryBuilder::begin()
9 // You can build query parameters by functions that accept a single argument,
10 .keyword_or("Python")
11 .keyword_or("機械学習")
12 // or can do by functions that accept a `Vec` argument.
13 .yms(vec![202110, 202111])
14 .order(OrderOption::Newer)
15 .count(15)
16 .build();
17 if let Ok(query) = query {
18 let client = ConnpassClient::new();
19 let res = client.send_request(query).await;
20 match res {
21 Ok(r) => println!("{:?}", r),
22 Err(err) => eprintln!("{:?}", err),
23 }
24 }
25}Trait Implementations§
Auto Trait Implementations§
impl Freeze for QueryBuilder
impl RefUnwindSafe for QueryBuilder
impl Send for QueryBuilder
impl Sync for QueryBuilder
impl Unpin for QueryBuilder
impl UnwindSafe for QueryBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more