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>
impl<T> Group<T>
Sourcepub fn validate(&self) -> Result<(), SCIMError>
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,
impl<T> Group<T>where
T: Serialize,
Sourcepub fn serialize(&self) -> Result<String, SCIMError>
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>where
T: DeserializeOwned,
impl<T> Group<T>where
T: DeserializeOwned,
Sourcepub fn deserialize(json: &str) -> Result<Self, SCIMError>
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 aGroup.
§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<'de, T> Deserialize<'de> for Group<T>where
T: Deserialize<'de>,
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>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. 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> 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