Skip to main content

agent_storage/family_invitation/
invitation_target_identity.rs

1//! Invitation typeExternal identity
2
3use super::InvitationStorageError;
4use serde::{Deserialize, Serialize};
5
6/// External identity an invitation is optionally restricted to.
7#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
8pub struct InvitationTargetIdentity {
9    pub provider: String,
10    pub subject: String,
11}
12
13impl InvitationTargetIdentity {
14    pub fn new(
15        provider: impl Into<String>,
16        subject: impl Into<String>,
17    ) -> Result<Self, InvitationStorageError> {
18        let provider = provider.into();
19        let subject = subject.into();
20        if provider.trim().is_empty() || subject.trim().is_empty() {
21            return Err(InvitationStorageError::EmptyTargetIdentity);
22        }
23        Ok(Self { provider, subject })
24    }
25}