Skip to main content

nautilus_rs/
lib.rs

1//! Official Rust SDK for the Verne Nautilus platform.
2//!
3//! Provides two services behind a single unified client:
4//!
5//! - **[Relay]** — Webhooks-as-a-Service: deliver events to subscribed HTTP endpoints.
6//! - **[Gate]** — Auth-as-a-Service: manage identities, issue short-lived access tokens,
7//!   and enforce authorization policies.
8//! - **[Passepartout]** — Telegram Auth-as-a-Service: sign users in with Telegram and
9//!   introspect the access tokens it issues.
10//! - **[Clockwork]** — Cron-as-a-Service: schedule recurring cron jobs and one-off delayed
11//!   jobs that invoke your HTTP endpoints, and inspect their execution history.
12//!
13//! # Quick start
14//!
15//! Add the crate to your `Cargo.toml`:
16//!
17//! ```toml
18//! [dependencies]
19//! nautilus-rs = "1.2"
20//! tokio = { version = "1", features = ["full"] }
21//! ```
22//!
23//! ## Using both services together
24//!
25//! ```no_run
26//! use nautilus_rs::{Verne, SendMessageParams};
27//! use serde_json::json;
28//!
29//! #[tokio::main]
30//! async fn main() -> Result<(), nautilus_rs::Error> {
31//!     let verne = Verne::builder()
32//!         .relay("vrn_relay_live_sk_…")
33//!         .gate("vrn_gate_live_sk_…")
34//!         .build()?;
35//!
36//!     // Send a webhook event
37//!     let msg = verne.relay()?.messages().send(SendMessageParams {
38//!         event_type: "order.placed".into(),
39//!         payload: json!({ "order_id": "ord_123" }),
40//!         ..Default::default()
41//!     }).await?;
42//!     println!("sent: {}", msg.id);
43//!
44//!     Ok(())
45//! }
46//! ```
47//!
48//! ## Using a single service
49//!
50//! You can also instantiate [`Relay`] or [`Gate`] on their own:
51//!
52//! ```no_run
53//! use nautilus_rs::Relay;
54//!
55//! let relay = Relay::new("vrn_relay_live_sk_…");
56//! ```
57//!
58//! # Error handling
59//!
60//! Every fallible call returns `Result<T, `[`Error`]`>`. Match on the variants to
61//! handle specific failure modes:
62//!
63//! ```no_run
64//! use nautilus_rs::{Error, Relay, SendMessageParams};
65//! use serde_json::json;
66//!
67//! # async fn run() {
68//! let relay = Relay::new("vrn_relay_live_sk_…");
69//! match relay.messages().send(SendMessageParams {
70//!     event_type: "ping".into(),
71//!     payload: json!({}),
72//!     ..Default::default()
73//! }).await {
74//!     Ok(msg) => println!("delivered: {}", msg.id),
75//!     Err(Error::Api(e)) => eprintln!("API {}: {}", e.status, e.message),
76//!     Err(e) => eprintln!("unexpected: {e}"),
77//! }
78//! # }
79//! ```
80//!
81//! # API key format
82//!
83//! Keys follow the pattern `vrn_<service>_<env>_sk_…`, for example:
84//! - `vrn_relay_live_sk_…`
85//! - `vrn_gate_test_sk_…`
86
87mod client;
88mod error;
89mod http;
90mod resources;
91mod types;
92
93pub use client::{Verne, VerneBuilder};
94pub use error::{ApiError, Error};
95pub use types::Paginated;
96
97pub use resources::relay::types::{ListMessagesParams, Message, SendMessageParams};
98pub use resources::relay::{MessagesClient, Relay, RelayBuilder};
99
100pub use resources::gate::types::{
101    AccessToken, AuthorizationDecision, AuthorizeParams, CreateIdentityParams, CreateTokenParams,
102    Identity, IdentityTraits, IdentityTraitsInput, JsonPatchOp, OidcProvider, SecuritySettings,
103    TokenInfo,
104};
105pub use resources::gate::{Gate, GateBuilder, IdentitiesClient, SettingsClient, TokensClient};
106
107pub use resources::passepartout::types::{
108    LoginStart, LoginStatus, TelegramUser, TokenIntrospection,
109};
110pub use resources::passepartout::{Passepartout, PassepartoutBuilder};
111
112pub use resources::clockwork::types::{
113    CreateCronJobParams, CreateDelayedJobParams, CronJob, DelayedJob, Execution,
114    UpdateCronJobParams,
115};
116pub use resources::clockwork::{Clockwork, ClockworkBuilder, CronJobsClient, DelayedJobsClient};