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
impl Name
Sourcepub 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>
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 displayfamily_name- The family name or last namegiven_name- The given name or first namemiddle_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 validErr(ValidationError)- If all fields are None/empty or any field violates validation rules
Sourcepub fn new_simple(
given_name: String,
family_name: String,
) -> ValidationResult<Self>
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 namefamily_name- The family name or last name
§Returns
Ok(Name)- If the names are validErr(ValidationError)- If any name violates validation rules
Sourcepub fn new_formatted(formatted: String) -> ValidationResult<Self>
pub fn new_formatted(formatted: String) -> ValidationResult<Self>
Sourcepub fn formatted(&self) -> Option<&str>
pub fn formatted(&self) -> Option<&str>
Create a Name instance without validation for internal use. Get the formatted name.
Sourcepub fn family_name(&self) -> Option<&str>
pub fn family_name(&self) -> Option<&str>
Get the family name.
Sourcepub fn given_name(&self) -> Option<&str>
pub fn given_name(&self) -> Option<&str>
Get the given name.
Sourcepub fn middle_name(&self) -> Option<&str>
pub fn middle_name(&self) -> Option<&str>
Get the middle name.
Sourcepub fn honorific_prefix(&self) -> Option<&str>
pub fn honorific_prefix(&self) -> Option<&str>
Get the honorific prefix.
Sourcepub fn honorific_suffix(&self) -> Option<&str>
pub fn honorific_suffix(&self) -> Option<&str>
Get the honorific suffix.
Sourcepub fn display_name(&self) -> Option<String>
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.
Sourcepub fn from_json(value: &Value) -> ValidationResult<Self>
pub fn from_json(value: &Value) -> ValidationResult<Self>
Create a Name from a JSON value.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Name
impl<'de> Deserialize<'de> for Name
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 SchemaConstructible for Name
impl SchemaConstructible for Name
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 ValueObject for Name
impl ValueObject for Name
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 Name
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> 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