Meta

Struct Meta 

Source
pub struct Meta {
    pub resource_type: String,
    pub created: DateTime<Utc>,
    pub last_modified: DateTime<Utc>,
    pub location: Option<String>,
    pub version: Option<String>,
}
Expand description

A validated SCIM meta attribute.

Meta represents the common metadata for SCIM resources as defined in RFC 7643. It enforces validation rules at construction time, ensuring that only valid meta attributes can exist in the system.

§Validation Rules

  • Resource type must not be empty
  • Created timestamp must be valid ISO 8601 format
  • Last modified timestamp must be valid ISO 8601 format
  • Last modified must not be before created timestamp
  • Location URI, if provided, must be valid format
  • Version, if provided, must follow ETag format

§Examples

use scim_server::resource::value_objects::Meta;
use chrono::Utc;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let now = Utc::now();
    let meta = Meta::new(
        "User".to_string(),
        now,
        now,
        Some("https://example.com/Users/123".to_string()),
        Some("123-456".to_string())
    )?;
    println!("Resource type: {}", meta.resource_type());

    Ok(())
}

Fields§

§resource_type: String§created: DateTime<Utc>§last_modified: DateTime<Utc>§location: Option<String>§version: Option<String>

Implementations§

Source§

impl Meta

Source

pub fn new( resource_type: String, created: DateTime<Utc>, last_modified: DateTime<Utc>, location: Option<String>, version: Option<String>, ) -> ValidationResult<Self>

Create a new Meta with full attributes.

This is the primary constructor that enforces all validation rules. Use this method when creating Meta instances from untrusted input.

§Arguments
  • resource_type - The SCIM resource type (e.g., “User”, “Group”)
  • created - The resource creation timestamp
  • last_modified - The resource last modification timestamp
  • location - Optional location URI for the resource
  • version - Optional version identifier (raw format)
§Returns
  • Ok(Meta) - If all values are valid
  • Err(ValidationError) - If any value violates validation rules
Source

pub fn new_simple( resource_type: String, created: DateTime<Utc>, last_modified: DateTime<Utc>, ) -> ValidationResult<Self>

Create a simple Meta with just resource type and timestamps.

Convenience constructor for creating meta attributes without optional fields.

§Arguments
  • resource_type - The SCIM resource type
  • created - The resource creation timestamp
  • last_modified - The resource last modification timestamp
§Returns
  • Ok(Meta) - If the values are valid
  • Err(ValidationError) - If any value violates validation rules
Source

pub fn new_for_creation(resource_type: String) -> ValidationResult<Self>

Create a Meta for a new resource with current timestamp.

Convenience constructor for creating meta attributes for new resources. Sets both created and last_modified to the current time.

§Arguments
  • resource_type - The SCIM resource type
§Returns
  • Ok(Meta) - If the resource type is valid
  • Err(ValidationError) - If the resource type violates validation rules
Source

pub fn resource_type(&self) -> &str

Get the resource type.

Source

pub fn created(&self) -> DateTime<Utc>

Get the created timestamp.

Source

pub fn last_modified(&self) -> DateTime<Utc>

Get the last modified timestamp.

Source

pub fn location(&self) -> Option<&str>

Get the location URI.

Source

pub fn version(&self) -> Option<&str>

Get the version identifier.

Source

pub fn with_updated_timestamp(&self) -> Self

Create a new Meta with updated last modified timestamp.

This method creates a new Meta instance with the last_modified timestamp updated to the current time, preserving all other attributes.

Source

pub fn with_location(self, location: String) -> ValidationResult<Self>

Create a new Meta with a specific location.

This method creates a new Meta instance with the location set to the provided value, preserving all other attributes.

Source

pub fn with_version(self, version: String) -> ValidationResult<Self>

Create a new Meta with a specific version.

This method creates a new Meta instance with the version set to the provided value, preserving all other attributes.

Source

pub fn generate_location( base_url: &str, resource_type: &str, resource_id: &str, ) -> String

Generate a location URI for the resource.

Creates a standard SCIM location URI based on the base URL, resource type, and resource ID.

Trait Implementations§

Source§

impl Clone for Meta

Source§

fn clone(&self) -> Meta

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 Meta

Source§

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

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

impl<'de> Deserialize<'de> for Meta

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Meta

Source§

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

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

impl PartialEq for Meta

Source§

fn eq(&self, other: &Meta) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Meta

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Meta

Source§

impl StructuralPartialEq for Meta

Auto Trait Implementations§

§

impl Freeze for Meta

§

impl RefUnwindSafe for Meta

§

impl Send for Meta

§

impl Sync for Meta

§

impl Unpin for Meta

§

impl UnwindSafe for Meta

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,