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
impl Meta
Sourcepub fn new(
resource_type: String,
created: DateTime<Utc>,
last_modified: DateTime<Utc>,
location: Option<String>,
version: Option<String>,
) -> ValidationResult<Self>
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 timestamplast_modified- The resource last modification timestamplocation- Optional location URI for the resourceversion- Optional version identifier (raw format)
§Returns
Ok(Meta)- If all values are validErr(ValidationError)- If any value violates validation rules
Sourcepub fn new_simple(
resource_type: String,
created: DateTime<Utc>,
last_modified: DateTime<Utc>,
) -> ValidationResult<Self>
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 typecreated- The resource creation timestamplast_modified- The resource last modification timestamp
§Returns
Ok(Meta)- If the values are validErr(ValidationError)- If any value violates validation rules
Sourcepub fn new_for_creation(resource_type: String) -> ValidationResult<Self>
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 validErr(ValidationError)- If the resource type violates validation rules
Sourcepub fn resource_type(&self) -> &str
pub fn resource_type(&self) -> &str
Get the resource type.
Sourcepub fn last_modified(&self) -> DateTime<Utc>
pub fn last_modified(&self) -> DateTime<Utc>
Get the last modified timestamp.
Sourcepub fn with_updated_timestamp(&self) -> Self
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.
Sourcepub fn with_location(self, location: String) -> ValidationResult<Self>
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.
Sourcepub fn with_version(self, version: String) -> ValidationResult<Self>
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.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Meta
impl<'de> Deserialize<'de> for Meta
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Meta
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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