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