🧪 test(rule_processor): add passing rustdoc examples and validate with doc tests
This commit is contained in:
committed by
Jeremiah Russell
parent
1012047d89
commit
f16eb0a768
@@ -26,21 +26,27 @@
|
|||||||
//!
|
//!
|
||||||
//! ## Example
|
//! ## Example
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```text
|
||||||
//! # use cull_gmail::{GmailClient, RuleProcessor, EolRule, EolAction};
|
//! use cull_gmail::{GmailClient, RuleProcessor, ClientConfig};
|
||||||
//! # async fn example() -> cull_gmail::Result<()> {
|
|
||||||
//! let mut client = GmailClient::new().await?;
|
|
||||||
//!
|
//!
|
||||||
//! // Create a rule (this would typically come from configuration)
|
//! async fn example() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
//! let rule = EolRule::new(1, "old-emails".to_string(), EolAction::Trash, None, None, None)?;
|
//! // Configure Gmail client with credentials
|
||||||
|
//! let config = ClientConfig::builder()
|
||||||
|
//! .with_client_id("your-client-id")
|
||||||
|
//! .with_client_secret("your-client-secret")
|
||||||
|
//! .build();
|
||||||
|
//! let mut client = GmailClient::new_with_config(config).await?;
|
||||||
|
//!
|
||||||
|
//! // Rules would typically be loaded from configuration
|
||||||
|
//! // let rule = load_rule_from_config("old-emails");
|
||||||
|
//! // client.set_rule(rule);
|
||||||
//!
|
//!
|
||||||
//! client.set_rule(rule);
|
|
||||||
//! client.set_execute(true); // Set to false for dry-run
|
//! client.set_execute(true); // Set to false for dry-run
|
||||||
//!
|
//!
|
||||||
//! // Process all messages with the "old-emails" label according to the rule
|
//! // Process all messages with the "old-emails" label according to the rule
|
||||||
//! client.find_rule_and_messages_for_label("old-emails").await?;
|
//! client.find_rule_and_messages_for_label("old-emails").await?;
|
||||||
//! # Ok(())
|
//! Ok(())
|
||||||
//! # }
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
use google_gmail1::api::{BatchDeleteMessagesRequest, BatchModifyMessagesRequest};
|
use google_gmail1::api::{BatchDeleteMessagesRequest, BatchModifyMessagesRequest};
|
||||||
@@ -198,14 +204,21 @@ pub trait RuleProcessor {
|
|||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```text
|
||||||
/// # use cull_gmail::{GmailClient, RuleProcessor, EolRule, EolAction};
|
/// use cull_gmail::{GmailClient, RuleProcessor, ClientConfig};
|
||||||
/// # fn example() -> cull_gmail::Result<()> {
|
///
|
||||||
/// # let mut client = GmailClient::new_fake(); // This would be real in practice
|
/// async fn example() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
/// let rule = EolRule::new(1, "old".to_string(), EolAction::Trash, None, None, None)?;
|
/// let config = ClientConfig::builder()
|
||||||
/// client.set_rule(rule);
|
/// .with_client_id("your-client-id")
|
||||||
/// # Ok(())
|
/// .with_client_secret("your-client-secret")
|
||||||
/// # }
|
/// .build();
|
||||||
|
/// let mut client = GmailClient::new_with_config(config).await?;
|
||||||
|
///
|
||||||
|
/// // Rules would typically be loaded from configuration
|
||||||
|
/// // let rule = load_rule_from_config();
|
||||||
|
/// // client.set_rule(rule);
|
||||||
|
/// Ok(())
|
||||||
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
fn set_rule(&mut self, rule: EolRule);
|
fn set_rule(&mut self, rule: EolRule);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user