scim-rs 0.1.0

SCIM 2.0 types and helpers for Rust.
Documentation
//! Small SCIM 2.0 building blocks.
//!
//! This crate is intentionally minimal while the public API takes shape.
//!
//! ```
//! use scim_rs::{ResourceKind, CORE_USER_SCHEMA};
//!
//! assert_eq!(ResourceKind::User.schema_urn(), CORE_USER_SCHEMA);
//! assert_eq!(ResourceKind::Group.endpoint(), "/Groups");
//! ```

#![forbid(unsafe_code)]

/// SCIM 2.0 core User schema URN.
pub const CORE_USER_SCHEMA: &str = "urn:ietf:params:scim:schemas:core:2.0:User";

/// SCIM 2.0 core Group schema URN.
pub const CORE_GROUP_SCHEMA: &str = "urn:ietf:params:scim:schemas:core:2.0:Group";

/// SCIM 2.0 Enterprise User extension schema URN.
pub const ENTERPRISE_USER_SCHEMA: &str =
    "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User";

/// Built-in SCIM resource kinds defined by RFC 7643 and RFC 7644.
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "lowercase"))]
pub enum ResourceKind {
    /// SCIM User resources.
    User,
    /// SCIM Group resources.
    Group,
}

impl ResourceKind {
    /// Returns the core schema URN for this resource kind.
    #[must_use]
    pub const fn schema_urn(self) -> &'static str {
        match self {
            Self::User => CORE_USER_SCHEMA,
            Self::Group => CORE_GROUP_SCHEMA,
        }
    }

    /// Returns the standard collection endpoint for this resource kind.
    #[must_use]
    pub const fn endpoint(self) -> &'static str {
        match self {
            Self::User => "/Users",
            Self::Group => "/Groups",
        }
    }
}