pub struct ConnpassClient { /* private fields */ }Expand description
Async API client for accessing and fetching data from connpass API.
Implementations§
Source§impl ConnpassClient
impl ConnpassClient
Sourcepub fn new() -> Self
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
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}Sourcepub fn with_client(client: Client) -> Self
pub fn with_client(client: Client) -> Self
Initializes client with your own client.
Sourcepub async fn send_request(
self,
query: Query,
) -> ConnpassResult<ConnpassResponse>
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
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
impl Clone for ConnpassClient
Source§fn clone(&self) -> ConnpassClient
fn clone(&self) -> ConnpassClient
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ConnpassClient
impl !RefUnwindSafe for ConnpassClient
impl Send for ConnpassClient
impl Sync for ConnpassClient
impl Unpin for ConnpassClient
impl !UnwindSafe for ConnpassClient
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