ConnpassClient

Struct ConnpassClient 

Source
pub struct ConnpassClient { /* private fields */ }
Expand description

Async API client for accessing and fetching data from connpass API.

Implementations§

Source§

impl ConnpassClient

Source

pub fn new() -> Self

Examples found in repository?
examples/get_single_event.rs (line 8)
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 18)
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 with_client(client: Client) -> Self

Initializes client with your own client.

Source

pub async fn send_request( self, query: Query, ) -> ConnpassResult<ConnpassResponse>

Sends requests and gets response from API. The response is internally converted to response::ConnpassResponse with handling errors.

§Arguments

If no condition is set to query and it’s passed, the default options are applied. The defaults are described in the connpass API specification page.

§Example:
use connpass_rs::{client::ConnpassClient, query::builder::QueryBuilder};

#[tokio::main]
async fn main() {
    // fetch https://rust.connpass.com/event/228732/
    let query = QueryBuilder::begin().event_id(228732).build();
    if let Ok(query) = query {
        let client = ConnpassClient::new();
        let res = client.send_request(query).await;
        match res {
            Ok(r) => println!("{:?}", r),
            Err(err) => eprintln!("{:?}", err),
        }
    }
}
Examples found in repository?
examples/get_single_event.rs (line 9)
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 19)
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 Clone for ConnpassClient

Source§

fn clone(&self) -> ConnpassClient

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for ConnpassClient

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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