pleme_providers/lib.rs
1//! # pleme-providers
2//!
3//! Multi-provider integration library for Pleme platform services.
4//!
5//! ## Philosophy
6//!
7//! This library implements the **Strategy Pattern** for integrating multiple external providers:
8//! - Single interface for multiple implementations
9//! - Runtime provider selection via registry
10//! - Consistent error handling across providers
11//! - Capability negotiation
12//!
13//! ## Use Cases
14//!
15//! - **Product Catalog**: Multiple dropshipping providers (CJ, EPROLO, Alibaba, etc.)
16//! - **Payment Processing**: Multiple payment gateways (Stripe, PayPal, Mercado Pago, PIX)
17//! - **Shipping**: Multiple carriers (Correios, FedEx, DHL)
18//! - **Email**: Multiple email services (SES, SendGrid, Mailgun)
19//! - **SMS**: Multiple SMS providers (Twilio, Vonage)
20//!
21//! ## Usage
22//!
23//! ```rust
24//! use pleme_providers::{Provider, ProviderRegistry, ProviderCapabilities, ProviderBatch, ProviderError};
25//! use async_trait::async_trait;
26//!
27//! // Define your domain-specific item type
28//! #[derive(Clone)]
29//! struct Product {
30//! id: String,
31//! name: String,
32//! }
33//!
34//! // Implement the Provider trait for your specific provider
35//! struct MyDropshipProvider;
36//!
37//! #[async_trait]
38//! impl Provider for MyDropshipProvider {
39//! type Item = Product;
40//! type Filter = ();
41//! type Pagination = ();
42//!
43//! fn provider_id(&self) -> &str { "my-provider" }
44//! fn provider_name(&self) -> &str { "My Provider" }
45//! fn capabilities(&self) -> ProviderCapabilities {
46//! ProviderCapabilities::default()
47//! }
48//!
49//! async fn fetch_items(
50//! &self,
51//! _filter: Self::Filter,
52//! _pagination: Self::Pagination,
53//! ) -> Result<ProviderBatch<Self::Item>, ProviderError> {
54//! Ok(ProviderBatch::empty())
55//! }
56//!
57//! async fn validate_credentials(&self) -> Result<(), ProviderError> {
58//! Ok(())
59//! }
60//! }
61//!
62//! // Use the registry to manage multiple providers
63//! # async fn example() {
64//! let mut registry = ProviderRegistry::new();
65//! registry.register(std::sync::Arc::new(MyDropshipProvider));
66//!
67//! let provider = registry.get("my-provider").expect("Provider not found");
68//! # }
69//! ```
70
71pub mod provider;
72pub mod registry;
73pub mod capabilities;
74pub mod error;
75pub mod batch;
76
77pub use provider::Provider;
78pub use registry::ProviderRegistry;
79pub use capabilities::ProviderCapabilities;
80pub use error::ProviderError;
81pub use batch::ProviderBatch;
82
83/// Result type for provider operations
84pub type Result<T> = std::result::Result<T, ProviderError>;