QueryBuilder

Struct QueryBuilder 

Source
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:

  1. functions that can accept a single argument.
  2. functions that can accept a Vec type 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.

Source

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
Hide additional 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}
Source

pub fn event_ids(self, ids: Vec<u32>) -> Self

Source

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}
Source

pub fn keywords(self, keywords: Vec<String>) -> Self

Source

pub fn keyword(self, keyword: impl Into<String>) -> Self

Source

pub fn keywords_or(self, keywords: Vec<String>) -> Self

Source

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}
Source

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}
Source

pub fn ym(self, ym: u32) -> Self

Source

pub fn ymds(self, ymd: Vec<u32>) -> Self

Source

pub fn ymd(self, ymd: u32) -> Self

Source

pub fn nicknames(self, nickname: Vec<String>) -> Self

Source

pub fn nickname(self, nickname: impl Into<String>) -> Self

Source

pub fn owner_nicknames(self, owner_nickname: Vec<String>) -> Self

Source

pub fn owner_nickname(self, owner_nickname: impl Into<String>) -> Self

Source

pub fn series_ids(self, series_ids: Vec<u32>) -> Self

Source

pub fn series_id(self, series_id: u32) -> Self

Source

pub fn start(self, start: u32) -> Self

Source

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}
Source

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}
Source

pub fn format(self, format: impl Into<String>) -> Self

Source

pub fn build(self) -> Result<Query, ConnpassCliError>

Converts from QueryBuilder to Query with some validation checks. The following checks run in this function:

  1. validate the count value in range of 0 to 100.
  2. validate if the format value 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
Hide additional 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§

Source§

impl Default for QueryBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more