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
82
83
84
85
86
//!# Rspamd Client for Rust
//!
//! This crate provides an HTTP client for interacting with the Rspamd service in Rust.
//! It supports both synchronous and asynchronous operations using the `attohttpc` and
//! `reqwest` libraries, respectively.
//!
//! ## Features
//!
//! - **Sync**: Synchronous client using `attohttpc`.
//! - **Async**: Asynchronous client using `reqwest`.
//! - Persistent clients with connection pooling (async backend).
//! - Easily configurable with support for proxy, encryption, TLS and ZSTD compression.
//! - Supports scanning emails for spam scores and other metrics.
// Ensure async and sync features are mutually exclusive
compile_error!;
compile_error!;
pub use ;
pub use ;
/// ### Synchronous Client
///
/// This example demonstrates how to scan emails using the persistent
/// synchronous client.
///
/// ```rust,no_run
/// use rspamd_client::{config, RspamdSyncClient};
///
/// let config = config::Config::builder()
/// .base_url("http://localhost:11333".to_string())
/// .build();
/// let client = RspamdSyncClient::new(config).expect("cannot create client");
/// let email = "From: user@example.com\nTo: recipient@example.com\nSubject: Test\n\nThis is a test email.";
///
/// match client.scan(email, Default::default()) {
/// Ok(response) => println!("Scan result: {:?}", response),
/// Err(e) => eprintln!("Error scanning email: {}", e),
/// }
/// ```
pub use RspamdSyncClient;
pub use ;
/// ### Asynchronous Client
///
/// This example demonstrates how to scan emails using the persistent
/// asynchronous client. The underlying connection is pooled and reused
/// across calls.
///
/// ```rust,no_run
/// use rspamd_client::{config, RspamdAsyncClient};
/// # use tokio;
///
/// # #[tokio::main]
/// # async fn main() {
/// let config = config::Config::builder()
/// .base_url("http://localhost:11333".to_string())
/// .build();
/// let client = RspamdAsyncClient::new(config).expect("cannot create client");
/// let email = "From: user@example.com\nTo: recipient@example.com\nSubject: Test\n\nThis is a test email.";
///
/// match client.scan(email, Default::default()).await {
/// Ok(response) => println!("Scan result: {:?}", response),
/// Err(e) => eprintln!("Error scanning email: {}", e),
/// }
/// # }
/// ```
pub use RspamdAsyncClient;
pub use ;