Skip to main content

scim_rs/
lib.rs

1//! Small SCIM 2.0 building blocks.
2//!
3//! This crate is intentionally minimal while the public API takes shape.
4//!
5//! ```
6//! use scim_rs::{ResourceKind, CORE_USER_SCHEMA};
7//!
8//! assert_eq!(ResourceKind::User.schema_urn(), CORE_USER_SCHEMA);
9//! assert_eq!(ResourceKind::Group.endpoint(), "/Groups");
10//! ```
11
12#![forbid(unsafe_code)]
13
14/// SCIM 2.0 core User schema URN.
15pub const CORE_USER_SCHEMA: &str = "urn:ietf:params:scim:schemas:core:2.0:User";
16
17/// SCIM 2.0 core Group schema URN.
18pub const CORE_GROUP_SCHEMA: &str = "urn:ietf:params:scim:schemas:core:2.0:Group";
19
20/// SCIM 2.0 Enterprise User extension schema URN.
21pub const ENTERPRISE_USER_SCHEMA: &str =
22    "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User";
23
24/// Built-in SCIM resource kinds defined by RFC 7643 and RFC 7644.
25#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
26#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
27#[cfg_attr(feature = "serde", serde(rename_all = "lowercase"))]
28pub enum ResourceKind {
29    /// SCIM User resources.
30    User,
31    /// SCIM Group resources.
32    Group,
33}
34
35impl ResourceKind {
36    /// Returns the core schema URN for this resource kind.
37    #[must_use]
38    pub const fn schema_urn(self) -> &'static str {
39        match self {
40            Self::User => CORE_USER_SCHEMA,
41            Self::Group => CORE_GROUP_SCHEMA,
42        }
43    }
44
45    /// Returns the standard collection endpoint for this resource kind.
46    #[must_use]
47    pub const fn endpoint(self) -> &'static str {
48        match self {
49            Self::User => "/Users",
50            Self::Group => "/Groups",
51        }
52    }
53}