Struct Name

Source
pub struct Name {
    pub formatted: Option<String>,
    pub family_name: Option<String>,
    pub given_name: Option<String>,
    pub middle_name: Option<String>,
    pub honorific_prefix: Option<String>,
    pub honorific_suffix: Option<String>,
}
Expand description

A validated SCIM name attribute.

Name represents the components of a user’s real name as defined in RFC 7643. It enforces validation rules at construction time, ensuring that only valid name attributes can exist in the system.

§Validation Rules

  • At least one name component must be provided (not all fields can be empty/None)
  • Individual name components cannot be empty strings
  • All fields are optional but if provided must contain meaningful content

§Examples

use scim_server::resource::value_objects::Name;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create with full name components
    let name = Name::new(
        Some("Ms. Barbara J Jensen, III".to_string()),
        Some("Jensen".to_string()),
        Some("Barbara".to_string()),
        Some("Jane".to_string()),
        Some("Ms.".to_string()),
        Some("III".to_string())
    )?;

    // Create with minimal components
    let simple_name = Name::new_simple(
        "John".to_string(),
        "Doe".to_string()
    )?;

    Ok(())
}

Fields§

§formatted: Option<String>§family_name: Option<String>§given_name: Option<String>§middle_name: Option<String>§honorific_prefix: Option<String>§honorific_suffix: Option<String>

Implementations§

Source§

impl Name

Source

pub fn new( formatted: Option<String>, family_name: Option<String>, given_name: Option<String>, middle_name: Option<String>, honorific_prefix: Option<String>, honorific_suffix: Option<String>, ) -> ValidationResult<Self>

Create a new Name with all components.

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

§Arguments
  • formatted - The full name, formatted for display
  • family_name - The family name or last name
  • given_name - The given name or first name
  • middle_name - The middle name(s)
  • honorific_prefix - The honorific prefix or title (e.g., “Ms.”, “Dr.”)
  • honorific_suffix - The honorific suffix (e.g., “III”, “Jr.”)
§Returns
  • Ok(Name) - If at least one field is provided and all provided fields are valid
  • Err(ValidationError) - If all fields are None/empty or any field violates validation rules
Source

pub fn new_simple( given_name: String, family_name: String, ) -> ValidationResult<Self>

Create a simple Name with just given and family names.

Convenience constructor for creating basic name structures.

§Arguments
  • given_name - The given name or first name
  • family_name - The family name or last name
§Returns
  • Ok(Name) - If the names are valid
  • Err(ValidationError) - If any name violates validation rules
Source

pub fn new_formatted(formatted: String) -> ValidationResult<Self>

Create a Name with a formatted display name only.

Convenience constructor for cases where only a formatted name is available.

§Arguments
  • formatted - The full formatted name
§Returns
  • Ok(Name) - If the formatted name is valid
  • Err(ValidationError) - If the name violates validation rules
Source

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

Create a Name instance without validation for internal use. Get the formatted name.

Source

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

Get the family name.

Source

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

Get the given name.

Source

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

Get the middle name.

Source

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

Get the honorific prefix.

Source

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

Get the honorific suffix.

Source

pub fn display_name(&self) -> Option<String>

Generate a formatted display name from components.

Creates a formatted name string from the available name components if no explicit formatted name is provided.

§Returns

The formatted name if available, otherwise a constructed name from components, or None if no components are available.

Source

pub fn is_empty(&self) -> bool

Check if the name has any meaningful content.

Source

pub fn from_json(value: &Value) -> ValidationResult<Self>

Create a Name from a JSON value.

Trait Implementations§

Source§

impl Clone for Name

Source§

fn clone(&self) -> Name

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 Name

Source§

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

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

impl<'de> Deserialize<'de> for Name

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 Name

Source§

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

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

impl PartialEq for Name

Source§

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

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 Name

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 ValueObject for Name

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 Name

Source§

impl StructuralPartialEq for Name

Auto Trait Implementations§

§

impl Freeze for Name

§

impl RefUnwindSafe for Name

§

impl Send for Name

§

impl Sync for Name

§

impl Unpin for Name

§

impl UnwindSafe for Name

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,