pub struct EmailAddress {
pub value: String,
pub email_type: Option<String>,
pub primary: Option<bool>,
pub display: Option<String>,
}Expand description
A validated SCIM email address.
EmailAddress represents an email address with optional metadata like type and primary flag. It enforces validation rules at construction time, ensuring that only valid email addresses can exist in the system.
§Validation Rules
- Email value must not be empty
- Email value must be a valid string
- Email type, if provided, must not be empty
- Primary flag is optional
- Display name is optional
§Examples
use scim_server::resource::value_objects::EmailAddress;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Valid email address
let email = EmailAddress::new(
"bjensen@example.com".to_string(),
Some("work".to_string()),
Some(true),
Some("Barbara Jensen".to_string())
)?;
println!("Email: {}", email.value());
// Simple email without metadata
let simple_email = EmailAddress::new_simple("user@example.com".to_string())?;
Ok(())
}Fields§
§value: String§email_type: Option<String>§primary: Option<bool>§display: Option<String>Implementations§
Source§impl EmailAddress
impl EmailAddress
Sourcepub fn new(
value: String,
email_type: Option<String>,
primary: Option<bool>,
display: Option<String>,
) -> ValidationResult<Self>
pub fn new( value: String, email_type: Option<String>, primary: Option<bool>, display: Option<String>, ) -> ValidationResult<Self>
Create a new EmailAddress with full metadata.
This is the primary constructor that enforces all validation rules. Use this method when creating EmailAddress instances from untrusted input.
§Arguments
value- The email address string to validateemail_type- Optional type designation (e.g., “work”, “home”)primary- Optional flag indicating if this is the primary emaildisplay- Optional display name for the email
§Returns
Ok(EmailAddress)- If all values are validErr(ValidationError)- If any value violates validation rules
Sourcepub fn new_simple(value: String) -> ValidationResult<Self>
pub fn new_simple(value: String) -> ValidationResult<Self>
Sourcepub fn email_type(&self) -> Option<&str>
pub fn email_type(&self) -> Option<&str>
Get the email type.
Sourcepub fn is_primary(&self) -> bool
pub fn is_primary(&self) -> bool
Check if this is marked as the primary email.
Trait Implementations§
Source§impl Clone for EmailAddress
impl Clone for EmailAddress
Source§fn clone(&self) -> EmailAddress
fn clone(&self) -> EmailAddress
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for EmailAddress
impl Debug for EmailAddress
Source§impl<'de> Deserialize<'de> for EmailAddress
impl<'de> Deserialize<'de> for EmailAddress
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for EmailAddress
impl Display for EmailAddress
Source§impl Hash for EmailAddress
impl Hash for EmailAddress
Source§impl PartialEq for EmailAddress
impl PartialEq for EmailAddress
Source§impl SchemaConstructible for EmailAddress
impl SchemaConstructible for EmailAddress
Source§fn from_schema_and_value(
definition: &AttributeDefinition,
value: &Value,
) -> ValidationResult<Self>
fn from_schema_and_value( definition: &AttributeDefinition, value: &Value, ) -> ValidationResult<Self>
Create a value object from a JSON value and schema definition
Source§fn can_construct_from(definition: &AttributeDefinition) -> bool
fn can_construct_from(definition: &AttributeDefinition) -> bool
Check if this type can handle the given attribute definition
Source§fn constructor_priority() -> u8
fn constructor_priority() -> u8
Get the priority for this constructor (higher = preferred)
Used when multiple constructors might handle the same definition
Source§impl Serialize for EmailAddress
impl Serialize for EmailAddress
Source§impl TryFrom<&str> for EmailAddress
impl TryFrom<&str> for EmailAddress
Source§type Error = ValidationError
type Error = ValidationError
The type returned in the event of a conversion error.
Source§fn try_from(value: &str) -> ValidationResult<Self>
fn try_from(value: &str) -> ValidationResult<Self>
Performs the conversion.
Source§impl TryFrom<String> for EmailAddress
impl TryFrom<String> for EmailAddress
Source§type Error = ValidationError
type Error = ValidationError
The type returned in the event of a conversion error.
Source§fn try_from(value: String) -> ValidationResult<Self>
fn try_from(value: String) -> ValidationResult<Self>
Performs the conversion.
Source§impl ValueObject for EmailAddress
impl ValueObject for EmailAddress
Source§fn attribute_type(&self) -> AttributeType
fn attribute_type(&self) -> AttributeType
Get the SCIM attribute type this value object represents
Source§fn attribute_name(&self) -> &str
fn attribute_name(&self) -> &str
Get the schema attribute name this value object corresponds to
Source§fn to_json(&self) -> ValidationResult<Value>
fn to_json(&self) -> ValidationResult<Value>
Serialize the value object to JSON
Source§fn validate_against_schema(
&self,
definition: &AttributeDefinition,
) -> ValidationResult<()>
fn validate_against_schema( &self, definition: &AttributeDefinition, ) -> ValidationResult<()>
Validate the value object against a schema definition
Source§fn as_json_value(&self) -> Value
fn as_json_value(&self) -> Value
Get the raw value as a JSON Value for schema-agnostic operations
Source§fn supports_definition(&self, definition: &AttributeDefinition) -> bool
fn supports_definition(&self, definition: &AttributeDefinition) -> bool
Check if this value object supports the given attribute definition
Source§fn clone_boxed(&self) -> Box<dyn ValueObject>
fn clone_boxed(&self) -> Box<dyn ValueObject>
Clone the value object as a boxed trait object
impl Eq for EmailAddress
impl StructuralPartialEq for EmailAddress
Auto Trait Implementations§
impl Freeze for EmailAddress
impl RefUnwindSafe for EmailAddress
impl Send for EmailAddress
impl Sync for EmailAddress
impl Unpin for EmailAddress
impl UnwindSafe for EmailAddress
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
Mutably borrows from an owned value. Read more
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
Compare self to
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>
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 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>
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 moreSource§impl<T> TenantValidator for T
impl<T> TenantValidator for T
Source§fn validate_tenant_context(
&self,
expected_tenant_id: &str,
context: &RequestContext,
) -> Result<(), String>
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>
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>
fn require_tenant_context(&self, context: &RequestContext) -> Result<(), String>
Extract tenant context or return error for multi-tenant operations.