qstash_rs/lib.rs
1//! # qstash-rs
2//!
3//! qstash-rs is a crate that provides a convenient rust SDK
4//! for the [Upstash QStash](https://upstash.com) API.
5//!
6//!
7//! ## Publishing a JSON message
8//!
9//! The publish_json method provides a convenient way to easily publish a
10//! message to qstash.
11//!
12//! ```rust
13//! use qstash_rs::client::{Client, PublishRequest, PublishRequestUrl};
14//! use std::collections::HashMap;
15//!
16//! #[tokio::main]
17//! async fn main() {
18//! let qstash_client = Client::new("<QSTASH_TOKEN>", None, None).unwrap();
19//! match qstash_client
20//! .publish_json(
21//! PublishRequestUrl::Url("https://google.com".parse().expect("Could not parse URL")),
22//! HashMap::from([("test", "test")]),
23//! None,
24//! )
25//! .await {
26//! Ok(r) => println!("{:?}",r),
27//! Err(err) => println!("{:?}",err),
28//! };
29//! }
30//! ```
31//!
32//! If you wish to add extra options to this method use the third parameter options
33//! of type [`Option<PublishOptions>`](client/struct.PublishOptions.html)
34//!
35//! ## Publishing any message
36//!
37//! whilst the publish_json method provides a convenient and more straightforward way
38//! to call the API, the publish method provides all the available options that
39//! qstash offers through their REST API.
40//!
41//! ```rust
42//! use qstash_rs::client::{Client, PublishRequest, PublishRequestUrl};
43//!
44//! #[tokio::main]
45//! async fn main() {
46//! let qstash_client = Client::new("<QSTASH_TOKEN>", None, None).unwrap();
47//! match qstash_client
48//! .publish(PublishRequest::<String> {
49//! url: PublishRequestUrl::Url(
50//! "https://google.com"
51//! .parse()
52//! .expect("Could not convert to URL"),
53//! ),
54//! body: None,
55//! headers: None,
56//! delay: None,
57//! not_before: None,
58//! deduplication_id: None,
59//! content_based_deduplication: None,
60//! retries: None,
61//! callback: None,
62//! method: None,
63//! })
64//! .await
65//! {
66//! Ok(r) => {
67//! println!("Success: {:?}", r);
68//! }
69//! Err(e) => {
70//! panic!("Could not publish");
71//! }
72//! };
73//! }
74//!
75//! ```
76//! **Note**: Replace <QSTASH_TOKEN> with your actual API token.
77//!
78//! Happy coding!
79
80pub mod client;