Skip to main content

Group

Struct Group 

Source
pub struct Group<T = String> {
    pub schemas: Vec<String>,
    pub id: Option<T>,
    pub external_id: Option<String>,
    pub display_name: String,
    pub members: Option<Vec<Member<T>>>,
    pub meta: Option<Meta>,
}

Fields§

§schemas: Vec<String>§id: Option<T>§external_id: Option<String>§display_name: String§members: Option<Vec<Member<T>>>§meta: Option<Meta>

Implementations§

Source§

impl<T> Group<T>

Source

pub fn validate(&self) -> Result<(), SCIMError>

Validates a group.

This function checks if the group has schemas, id, and display_name. If any of these fields are missing, it returns an error.

§Arguments
  • group - A reference to a Group instance.
§Returns
  • Ok(()) - If the group is valid.
  • Err(SCIMError::MissingRequiredField) - If a required field is missing.
§Example
use scim_v2::models::group::Group;

let group = Group {
    schemas: vec!["urn:ietf:params:scim:schemas:core:2.0:Group".to_string()],
    id: Some("e9e30dba-f08f-4109-8486-d5c6a331660a".to_string()),
    external_id: None,
    display_name: "Tour Guides".to_string(),
    meta: None,
    members: None
};

match group.validate() {
    Ok(_) => println!("Group is valid."),
    Err(e) => println!("Group is invalid: {}", e),
}
Source§

impl<T> Group<T>
where T: Serialize,

Source

pub fn serialize(&self) -> Result<String, SCIMError>

Serializes the Group instance to a JSON string, using the custom SCIMError for error handling.

§Returns

This method returns a Result<String, SCIMError>, where Ok(String) contains the JSON string representation of the Group instance, and Err(SCIMError) contains the custom error encountered during serialization.

§Examples
use scim_v2::models::group::Group;

let group = Group {
    schemas: vec!["urn:ietf:params:scim:schemas:core:2.0:Group".to_string()],
    id: Some("e9e30dba-f08f-4109-8486-d5c6a331660a".to_string()),
    external_id: None,
    display_name: "Tour Guides".to_string(),
    meta: None,
    members: None
};

match group.serialize() {
    Ok(json) => println!("Serialized User: {}", json),
    Err(e) => println!("Serialization error: {}", e),
}
Source§

impl<T> Group<T>

Source

pub fn deserialize(json: &str) -> Result<Self, SCIMError>

Deserializes a JSON string into a Group instance, using the custom SCIMError for error handling.

§Parameters
  • json - A string slice that holds the JSON representation of a Group.
§Returns

This method returns a Result<Group, SCIMError>, where Ok(Group) is the deserialized Group instance, and Err(SCIMError) is the custom error encountered during deserialization.

§Examples
use scim_v2::models::group::Group;

let group_json = r#"{"schemas": ["urn:ietf:params:scim:schemas:core:2.0:Group"], "id": "e9e30dba-f08f-4109-8486-d5c6a331660a", "displayName": "Tour Guides"}"#;
match Group::<uuid::Uuid>::deserialize(group_json) {
    Ok(group) => println!("Deserialized Group: {:?}", group),
    Err(e) => println!("Deserialization error: {}", e),
}

Trait Implementations§

Source§

impl<T: Debug> Debug for Group<T>

Source§

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

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

impl<'de, T> Deserialize<'de> for Group<T>
where T: Deserialize<'de>,

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<T> Serialize for Group<T>
where T: Serialize,

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

Auto Trait Implementations§

§

impl<T> Freeze for Group<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Group<T>
where T: RefUnwindSafe,

§

impl<T> Send for Group<T>
where T: Send,

§

impl<T> Sync for Group<T>
where T: Sync,

§

impl<T> Unpin for Group<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Group<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for Group<T>
where T: UnwindSafe,

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> 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, 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>,