EmailAddress

Struct EmailAddress 

Source
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

Source

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 validate
  • email_type - Optional type designation (e.g., “work”, “home”)
  • primary - Optional flag indicating if this is the primary email
  • display - Optional display name for the email
§Returns
  • Ok(EmailAddress) - If all values are valid
  • Err(ValidationError) - If any value violates validation rules
Source

pub fn new_simple(value: String) -> ValidationResult<Self>

Create a simple EmailAddress with just the email value.

Convenience constructor for creating email addresses without metadata.

§Arguments
  • value - The email address string to validate
§Returns
  • Ok(EmailAddress) - If the value is valid
  • Err(ValidationError) - If the value violates validation rules
Source

pub fn value(&self) -> &str

Get the email address value.

Source

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

Get the email type.

Source

pub fn primary(&self) -> Option<bool>

Get the primary flag.

Source

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

Get the display name.

Source

pub fn is_primary(&self) -> bool

Check if this is marked as the primary email.

Trait Implementations§

Source§

impl Clone for EmailAddress

Source§

fn clone(&self) -> EmailAddress

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 EmailAddress

Source§

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

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

impl<'de> Deserialize<'de> for EmailAddress

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 EmailAddress

Source§

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

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

impl Hash for EmailAddress

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for EmailAddress

Source§

fn eq(&self, other: &EmailAddress) -> 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 SchemaConstructible for EmailAddress

Source§

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

Check if this type can handle the given attribute definition
Source§

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

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 TryFrom<&str> for EmailAddress

Source§

type Error = ValidationError

The type returned in the event of a conversion error.
Source§

fn try_from(value: &str) -> ValidationResult<Self>

Performs the conversion.
Source§

impl TryFrom<String> for EmailAddress

Source§

type Error = ValidationError

The type returned in the event of a conversion error.
Source§

fn try_from(value: String) -> ValidationResult<Self>

Performs the conversion.
Source§

impl ValueObject for EmailAddress

Source§

fn attribute_type(&self) -> AttributeType

Get the SCIM attribute type this value object represents
Source§

fn attribute_name(&self) -> &str

Get the schema attribute name this value object corresponds to
Source§

fn to_json(&self) -> ValidationResult<Value>

Serialize the value object to JSON
Source§

fn validate_against_schema( &self, definition: &AttributeDefinition, ) -> ValidationResult<()>

Validate the value object against a schema definition
Source§

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

Check if this value object supports the given attribute definition
Source§

fn clone_boxed(&self) -> Box<dyn ValueObject>

Clone the value object as a boxed trait object
Source§

fn as_any(&self) -> &dyn Any

Get type information for downcasting
Source§

impl Eq for EmailAddress

Source§

impl StructuralPartialEq for EmailAddress

Auto Trait Implementations§

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,