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
impl SchemaRegistry
Sourcepub fn new() -> Result<Self, Box<dyn Error>>
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().
Sourcepub fn with_embedded_schemas() -> Result<Self, Box<dyn Error>>
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.
Sourcepub fn from_schema_dir<P: AsRef<Path>>(
schema_dir: P,
) -> Result<Self, Box<dyn Error>>
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.
Sourcepub fn get_schemas(&self) -> Vec<&Schema>
pub fn get_schemas(&self) -> Vec<&Schema>
Get all available schemas.
Sourcepub fn get_schema(&self, id: &str) -> Option<&Schema>
pub fn get_schema(&self, id: &str) -> Option<&Schema>
Get a specific schema by ID.
Sourcepub fn get_user_schema(&self) -> &Schema
pub fn get_user_schema(&self) -> &Schema
Get the core User schema.
pub fn get_group_schema(&self) -> &Schema
Sourcepub fn add_schema(&mut self, schema: Schema) -> Result<(), Box<dyn Error>>
pub fn add_schema(&mut self, schema: Schema) -> Result<(), Box<dyn Error>>
Add a schema to the registry.
Sourcepub fn get_schema_by_id(&self, schema_id: &str) -> Option<&Schema>
pub fn get_schema_by_id(&self, schema_id: &str) -> Option<&Schema>
Get a schema by ID.
Source§impl SchemaRegistry
impl SchemaRegistry
Sourcepub async fn validate_json_resource_with_provider<P>(
&self,
resource_type: &str,
resource_json: &Value,
context: OperationContext,
provider: &P,
request_context: &RequestContext,
) -> ValidationResult<()>where
P: ResourceProvider,
pub async fn validate_json_resource_with_provider<P>(
&self,
resource_type: &str,
resource_json: &Value,
context: OperationContext,
provider: &P,
request_context: &RequestContext,
) -> ValidationResult<()>where
P: ResourceProvider,
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 validatecontext- The operation context (Create, Update, or Patch)provider- The resource provider for uniqueness validationrequest_context- The request context for tenant/scope information
§Returns
Ok(())if validation passesErr(ValidationError)if validation fails
Sourcepub fn validate_resource_hybrid(
&self,
resource: &Resource,
) -> ValidationResult<()>
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.
Sourcepub fn validate_json_resource_with_context(
&self,
resource_type: &str,
resource_json: &Value,
context: OperationContext,
) -> ValidationResult<()>
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 validatecontext- The operation context (Create, Update, or Patch)
§Returns
Ok(())if validation passesErr(ValidationError)if validation fails with specific error details
Sourcepub fn validate_resource(
&self,
schema: &Schema,
resource: &Value,
) -> ValidationResult<()>
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
impl Clone for SchemaRegistry
Source§fn clone(&self) -> SchemaRegistry
fn clone(&self) -> SchemaRegistry
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more