Skip to main content

pcs_external/
lib.rs

1//! PCS External API client for Ppoppo Chat System.
2//!
3//! Provides a domain-typed gRPC client for the PCS External Developer
4//! Platform (`chat.external` package).
5//!
6//! # Hot path (v0.2.0+)
7//!
8//! Most consumers want [`pcs_port::GrpcPcsAdapter`] — a port abstraction
9//! that hides tonic/prost types behind two domain-typed methods
10//! (`send_alert`, `get_send_status`) plus an explicit escape hatch
11//! ([`pcs_port::RawPcsChannel`]) for the long tail of admin / template /
12//! polling RPCs.
13//!
14//! ```no_run
15//! # async fn example() -> Result<(), pcs_external::Error> {
16//! use pcs_external::pcs_port::{
17//!     GrpcPcsAdapter, PcsExternalPort, RecipientList, Ppnum, TemplateId,
18//! };
19//!
20//! let pcs = GrpcPcsAdapter::from_env().await?;
21//! let recipients = RecipientList::from_ppnums(vec![
22//!     Ppnum::try_new("12345678901").map_err(|e| pcs_external::Error::External(e.to_string()))?,
23//! ])
24//! .map_err(|e| pcs_external::Error::External(e.to_string()))?;
25//! let _ = pcs
26//!     .send_alert(&TemplateId::new("tmpl_attendance_v1"), &recipients, None)
27//!     .await;
28//! # Ok(())
29//! # }
30//! ```
31//!
32//! # Tests
33//!
34//! Behind `test-support`, [`pcs_port::MemoryPcsExternal`] is an
35//! in-process fake of [`pcs_port::PcsExternalPort`] suitable for
36//! consumer-side integration tests without a live PCS endpoint.
37//!
38//! # Legacy surface
39//!
40//! [`connect`], [`auth_request`], [`ExternalChannel`] remain available
41//! for v0.1.0 consumers and for the [`pcs_port::RawPcsChannel`] escape
42//! hatch. The free `connect` / `auth_request` entry points are marked
43//! `#[deprecated]` and slated for removal in v0.3.0.
44
45pub mod error;
46pub mod external;
47pub mod pcs_port;
48
49// Re-exports
50pub use error::Error;
51pub use external::{ExternalChannel, auth_request};
52#[allow(deprecated)]
53pub use external::connect;
54pub use prost_types;
55pub use tonic;