pcs-external 0.3.0

Ppoppo Chat System (PCS) External API client -- gRPC client for the External Developer Platform
Documentation
//! Sealed scope-set type family for [`crate::PcsExternalClient<S>`].
//!
//! The four scope sets map to the OAuth2 scopes your app requested when
//! calling `PasTokenUrl` with the `client_credentials` grant. Methods on
//! [`crate::PcsExternalClient`] are gated by capability marker traits
//! (`SendAlertCapable`, `GetSendStatusCapable`) so calling a method your
//! app isn't authorised for is a **compile-time error** (E0277), not a
//! runtime rejection.
//!
//! ## Compile-time enforcement example
//!
//! ```compile_fail,E0277
//! use pcs_external::{PcsExternalClient, scopes::ReadOnly};
//!
//! fn try_send(client: &PcsExternalClient<ReadOnly>) {
//!     // send_alert requires SendAlertCapable; ReadOnly doesn't satisfy it.
//!     // This line must not compile.
//!     let _ = client.send_alert(todo!(), todo!(), None);
//! }
//! ```

mod sealed {
    pub trait Seal {}
}

/// Parent marker for all PCS External API scope sets.
///
/// Sealed — cannot be implemented outside this crate.
pub trait PcsExternalScopeSet: sealed::Seal + Send + Sync + 'static {}

/// Read-only access: `get_send_status` only.
pub struct ReadOnly;
/// Send-only access: `send_alert` only. Used by RCW notification adapter.
pub struct SendOnly;
/// Read + send: `send_alert` + `get_send_status`.
pub struct ReadAndSend;
/// Full access: all methods.
pub struct FullAccess;

impl sealed::Seal for ReadOnly {}
impl sealed::Seal for SendOnly {}
impl sealed::Seal for ReadAndSend {}
impl sealed::Seal for FullAccess {}

impl PcsExternalScopeSet for ReadOnly {}
impl PcsExternalScopeSet for SendOnly {}
impl PcsExternalScopeSet for ReadAndSend {}
impl PcsExternalScopeSet for FullAccess {}

/// Capability marker: scope set may call `send_alert`.
pub trait SendAlertCapable: PcsExternalScopeSet {}
impl SendAlertCapable for SendOnly {}
impl SendAlertCapable for ReadAndSend {}
impl SendAlertCapable for FullAccess {}

/// Capability marker: scope set may call `get_send_status`.
pub trait GetSendStatusCapable: PcsExternalScopeSet {}
impl GetSendStatusCapable for ReadOnly {}
impl GetSendStatusCapable for ReadAndSend {}
impl GetSendStatusCapable for FullAccess {}