SchemaRegistry

Struct SchemaRegistry 

Source
pub struct SchemaRegistry { /* private fields */ }
Expand description

Registry for SCIM schemas with validation capabilities.

The schema registry manages all available schemas and provides validation services for resources. For the MVP, it contains only the hardcoded core User schema.

Implementations§

Source§

impl SchemaRegistry

Source

pub fn new() -> Result<Self, Box<dyn Error>>

Create a new schema registry with embedded core schemas.

This method uses the schemas embedded in the library and doesn’t require external schema files. For loading schemas from files, use from_schema_dir().

Source

pub fn with_embedded_schemas() -> Result<Self, Box<dyn Error>>

Create a new schema registry with embedded core schemas.

This method uses the schemas embedded in the library and doesn’t require external schema files. This is the recommended method for schema discovery functionality as it works without any file dependencies.

Source

pub fn from_schema_dir<P: AsRef<Path>>( schema_dir: P, ) -> Result<Self, Box<dyn Error>>

Create a schema registry by loading schemas from a directory.

Source

pub fn get_schemas(&self) -> Vec<&Schema>

Get all available schemas.

Source

pub fn get_schema(&self, id: &str) -> Option<&Schema>

Get a specific schema by ID.

Source

pub fn get_user_schema(&self) -> &Schema

Get the core User schema.

Source

pub fn get_group_schema(&self) -> &Schema

Get the core Group schema.

Source

pub fn add_schema(&mut self, schema: Schema) -> Result<(), Box<dyn Error>>

Add a schema to the registry.

Source

pub fn get_schema_by_id(&self, schema_id: &str) -> Option<&Schema>

Get a schema by ID.

Source§

impl SchemaRegistry

Source

pub async fn validate_json_resource_with_provider<P>( &self, resource_type: &str, resource_json: &Value, context: OperationContext, provider: &P, request_context: &RequestContext, ) -> ValidationResult<()>

Validate a SCIM resource with async provider integration for uniqueness checks.

This method performs both synchronous schema validation and async provider-based uniqueness validation when required by the schema.

§Arguments
  • resource_type - The type of resource to validate (e.g., “User”, “Group”)
  • resource_json - The JSON resource data to validate
  • context - The operation context (Create, Update, or Patch)
  • provider - The resource provider for uniqueness validation
  • request_context - The request context for tenant/scope information
§Returns
  • Ok(()) if validation passes
  • Err(ValidationError) if validation fails
Source

pub fn validate_resource_hybrid( &self, resource: &Resource, ) -> ValidationResult<()>

Validate a SCIM resource using the hybrid value object approach.

This method validates both the type-safe core attributes and the schema-driven complex attributes, providing comprehensive validation while maintaining performance and flexibility.

Source

pub fn validate_json_resource_with_context( &self, resource_type: &str, resource_json: &Value, context: OperationContext, ) -> ValidationResult<()>

Validate a raw JSON resource (legacy support).

This method first constructs a Resource from JSON (which validates core primitives) and then performs schema validation. Validate a SCIM resource with operation context awareness.

This method performs context-aware validation that varies based on the operation:

  • CREATE: Rejects client-provided IDs and readonly attributes
  • UPDATE/PATCH: Requires IDs and handles readonly attributes appropriately
§Arguments
  • resource_type - The type of resource to validate (e.g., “User”, “Group”)
  • resource_json - The JSON resource data to validate
  • context - The operation context (Create, Update, or Patch)
§Returns
  • Ok(()) if validation passes
  • Err(ValidationError) if validation fails with specific error details
Source

pub fn validate_resource( &self, schema: &Schema, resource: &Value, ) -> ValidationResult<()>

Validate a resource against a specific schema (legacy method).

This method validates a JSON resource against a schema definition, checking attributes, types, and constraints.

Trait Implementations§

Source§

impl Clone for SchemaRegistry

Source§

fn clone(&self) -> SchemaRegistry

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SchemaRegistry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SchemaRegistry

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> TenantValidator for T

Source§

fn validate_tenant_context( &self, expected_tenant_id: &str, context: &RequestContext, ) -> Result<(), String>

Validate that the context has the expected tenant.
Source§

fn validate_single_tenant_context( &self, context: &RequestContext, ) -> Result<(), String>

Validate that the context is for single-tenant operation.
Source§

fn require_tenant_context(&self, context: &RequestContext) -> Result<(), String>

Extract tenant context or return error for multi-tenant operations.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.