pub struct ResourceId(/* private fields */);Expand description
A validated SCIM resource identifier.
ResourceId represents a unique identifier for a SCIM resource. It enforces validation rules at construction time, ensuring that only valid resource IDs can exist in the system.
§Validation Rules
- Must not be empty
- Must be a valid string
- Additional format rules may be added in the future
§Examples
use scim_server::resource::value_objects::ResourceId;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Valid resource ID
let id = ResourceId::new("2819c223-7f76-453a-919d-413861904646".to_string())?;
println!("Resource ID: {}", id.as_str());
// Invalid resource ID - returns ValidationError
let invalid = ResourceId::new("".to_string());
assert!(invalid.is_err());
Ok(())
}Implementations§
Source§impl ResourceId
impl ResourceId
Sourcepub fn new(value: String) -> ValidationResult<Self>
pub fn new(value: String) -> ValidationResult<Self>
Create a new ResourceId with validation.
This is the primary constructor that enforces all validation rules. Use this method when creating ResourceId instances from untrusted input.
§Arguments
value- The string value to validate and wrap
§Returns
Ok(ResourceId)- If the value is validErr(ValidationError)- If the value violates validation rules
§Examples
use scim_server::resource::value_objects::ResourceId;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let id = ResourceId::new("user-123".to_string())?;
let empty_id = ResourceId::new("".to_string()); // Error
assert!(empty_id.is_err());
Ok(())
}Sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Get the string representation of the ResourceId.
Returns a reference to the underlying string value. This is safe because the value is guaranteed to be valid by construction.
§Examples
use scim_server::resource::value_objects::ResourceId;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let id = ResourceId::new("test-id".to_string())?;
assert_eq!(id.as_str(), "test-id");
Ok(())
}Sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Get the owned string value of the ResourceId.
Consumes the ResourceId and returns the underlying string. Use this when you need to transfer ownership of the string value.
§Examples
use scim_server::resource::value_objects::ResourceId;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let id = ResourceId::new("test-id".to_string())?;
let owned_string = id.into_string();
assert_eq!(owned_string, "test-id");
Ok(())
}Trait Implementations§
Source§impl Clone for ResourceId
impl Clone for ResourceId
Source§fn clone(&self) -> ResourceId
fn clone(&self) -> ResourceId
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ResourceId
impl Debug for ResourceId
Source§impl<'de> Deserialize<'de> for ResourceId
impl<'de> Deserialize<'de> for ResourceId
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>,
Source§impl Display for ResourceId
impl Display for ResourceId
Source§impl Hash for ResourceId
impl Hash for ResourceId
Source§impl PartialEq for ResourceId
impl PartialEq for ResourceId
Source§impl SchemaConstructible for ResourceId
impl SchemaConstructible for ResourceId
Source§fn from_schema_and_value(
definition: &AttributeDefinition,
value: &Value,
) -> ValidationResult<Self>
fn from_schema_and_value( definition: &AttributeDefinition, value: &Value, ) -> ValidationResult<Self>
Source§fn can_construct_from(definition: &AttributeDefinition) -> bool
fn can_construct_from(definition: &AttributeDefinition) -> bool
Source§fn constructor_priority() -> u8
fn constructor_priority() -> u8
Source§impl Serialize for ResourceId
impl Serialize for ResourceId
Source§impl TryFrom<&str> for ResourceId
Convert from &str to ResourceId with validation.
impl TryFrom<&str> for ResourceId
Convert from &str to ResourceId with validation.
Source§type Error = ValidationError
type Error = ValidationError
Source§fn try_from(value: &str) -> ValidationResult<Self>
fn try_from(value: &str) -> ValidationResult<Self>
Source§impl TryFrom<String> for ResourceId
Convert from String to ResourceId with validation.
impl TryFrom<String> for ResourceId
Convert from String to ResourceId with validation.
Source§type Error = ValidationError
type Error = ValidationError
Source§fn try_from(value: String) -> ValidationResult<Self>
fn try_from(value: String) -> ValidationResult<Self>
Source§impl ValueObject for ResourceId
impl ValueObject for ResourceId
Source§fn attribute_type(&self) -> AttributeType
fn attribute_type(&self) -> AttributeType
Source§fn attribute_name(&self) -> &str
fn attribute_name(&self) -> &str
Source§fn to_json(&self) -> ValidationResult<Value>
fn to_json(&self) -> ValidationResult<Value>
Source§fn validate_against_schema(
&self,
definition: &AttributeDefinition,
) -> ValidationResult<()>
fn validate_against_schema( &self, definition: &AttributeDefinition, ) -> ValidationResult<()>
Source§fn as_json_value(&self) -> Value
fn as_json_value(&self) -> Value
Source§fn supports_definition(&self, definition: &AttributeDefinition) -> bool
fn supports_definition(&self, definition: &AttributeDefinition) -> bool
Source§fn clone_boxed(&self) -> Box<dyn ValueObject>
fn clone_boxed(&self) -> Box<dyn ValueObject>
impl Eq for ResourceId
impl StructuralPartialEq for ResourceId
Auto Trait Implementations§
impl Freeze for ResourceId
impl RefUnwindSafe for ResourceId
impl Send for ResourceId
impl Sync for ResourceId
impl Unpin for ResourceId
impl UnwindSafe for ResourceId
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