saml_rs/model/
identifiers.rs1use crate::error::SamlError;
2
3#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5pub struct MessageId(String);
6
7impl MessageId {
8 pub fn try_new(value: impl Into<String>) -> Result<Self, SamlError> {
14 let value = value.into();
15 if value.trim().is_empty() {
16 return Err(SamlError::Invalid(
17 "SAML message ID must not be empty".into(),
18 ));
19 }
20 Ok(Self(value))
21 }
22
23 pub fn as_str(&self) -> &str {
25 &self.0
26 }
27}
28
29#[derive(Debug, Clone, PartialEq, Eq, Hash)]
31pub struct AssertionId(String);
32
33impl AssertionId {
34 pub fn try_new(value: impl Into<String>) -> Result<Self, SamlError> {
40 let value = value.into();
41 if value.trim().is_empty() {
42 return Err(SamlError::Invalid("assertion ID must not be empty".into()));
43 }
44 Ok(Self(value))
45 }
46
47 pub fn as_str(&self) -> &str {
49 &self.0
50 }
51}
52
53#[derive(Debug, Clone, PartialEq, Eq, Hash)]
55pub struct SamlInstant(String);
56
57impl SamlInstant {
58 pub fn try_new(value: impl Into<String>) -> Result<Self, SamlError> {
65 let value = value.into();
66 if value.trim().is_empty() {
67 return Err(SamlError::Invalid("SAML instant must not be empty".into()));
68 }
69 Ok(Self(value))
70 }
71
72 pub fn as_str(&self) -> &str {
74 &self.0
75 }
76}
77
78#[derive(Debug, Clone, PartialEq, Eq, Hash)]
80pub struct SessionIndex(String);
81
82impl SessionIndex {
83 pub fn try_new(value: impl Into<String>) -> Result<Self, SamlError> {
89 let value = value.into();
90 if value.trim().is_empty() {
91 return Err(SamlError::Invalid("SessionIndex must not be empty".into()));
92 }
93 Ok(Self(value))
94 }
95
96 pub fn as_str(&self) -> &str {
98 &self.0
99 }
100}