Skip to content

Commit 73c5912

Browse files
committed
fix
1 parent bd7e9c9 commit 73c5912

File tree

1 file changed

+16
-19
lines changed
  • rust/catalyst-types/src/catalyst_id

1 file changed

+16
-19
lines changed

rust/catalyst-types/src/catalyst_id/mod.rs

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,12 @@ struct CatalystIdInner {
6363
/// - `true`: The key is used for encryption.
6464
/// - `false`: The key is used for signing (signature key).
6565
encryption: bool,
66-
/// Indicates if this is an `id` type, or a `uri` type o.
67-
/// Used by the serialization functions.
68-
/// `true` = format as an `Id`
69-
/// `false` = format as a `Uri`
70-
r#type: CatalysIdType,
66+
/// Catalys ID type (URI, ID or AdminURI)
67+
r#type: CatalystIdType,
7168
}
7269

7370
#[derive(Debug, Clone, Default)]
74-
enum CatalysIdType {
71+
enum CatalystIdType {
7572
/// format as an `Id`
7673
Id,
7774
/// format as a `Uri`
@@ -153,7 +150,7 @@ impl CatalystId {
153150
role: RoleId::default(), // Defaulted, use `with_role()` to change it.
154151
rotation: KeyRotation::default(), // Defaulted, use `with_rotation()` to change it.
155152
encryption: false, // Defaulted, use `with_encryption()` to change it.
156-
r#type: CatalysIdType::default(), // Default to `URI` formatted.
153+
r#type: CatalystIdType::default(), // Default to `URI` formatted.
157154
});
158155

159156
Self { inner }
@@ -164,7 +161,7 @@ impl CatalystId {
164161
pub fn as_uri(self) -> Self {
165162
let inner = Arc::try_unwrap(self.inner).unwrap_or_else(|v| (*v).clone());
166163
let inner = Arc::new(CatalystIdInner {
167-
r#type: CatalysIdType::Uri,
164+
r#type: CatalystIdType::Uri,
168165
..inner
169166
});
170167
Self { inner }
@@ -175,7 +172,7 @@ impl CatalystId {
175172
pub fn as_id(self) -> Self {
176173
let inner = Arc::try_unwrap(self.inner).unwrap_or_else(|v| (*v).clone());
177174
let inner = Arc::new(CatalystIdInner {
178-
r#type: CatalysIdType::Id,
175+
r#type: CatalystIdType::Id,
179176
..inner
180177
});
181178
Self { inner }
@@ -186,7 +183,7 @@ impl CatalystId {
186183
pub fn as_admin(self) -> Self {
187184
let inner = Arc::try_unwrap(self.inner).unwrap_or_else(|v| (*v).clone());
188185
let inner = Arc::new(CatalystIdInner {
189-
r#type: CatalysIdType::AdminUri,
186+
r#type: CatalystIdType::AdminUri,
190187
..inner
191188
});
192189
Self { inner }
@@ -195,19 +192,19 @@ impl CatalystId {
195192
/// Was `CatalystId` formatted as an id when it was parsed.
196193
#[must_use]
197194
pub fn is_id(&self) -> bool {
198-
matches!(self.inner.r#type, CatalysIdType::Id)
195+
matches!(self.inner.r#type, CatalystIdType::Id)
199196
}
200197

201198
/// Is `CatalystId` formatted as an Admin.
202199
#[must_use]
203200
pub fn is_admin(&self) -> bool {
204-
matches!(self.inner.r#type, CatalysIdType::AdminUri)
201+
matches!(self.inner.r#type, CatalystIdType::AdminUri)
205202
}
206203

207204
/// Was `CatalystId` formatted as an uri when it was parsed.
208205
#[must_use]
209206
pub fn is_uri(&self) -> bool {
210-
matches!(self.inner.r#type, CatalysIdType::Uri)
207+
matches!(self.inner.r#type, CatalystIdType::Uri)
211208
}
212209

213210
/// Add or change the username in a Catalyst ID URI.
@@ -629,17 +626,17 @@ impl FromStr for CatalystId {
629626
let uri = Uri::parse(s.to_owned())?;
630627
// Check if its the correct scheme.
631628
let r#type = if uri.scheme() == Self::SCHEME {
632-
CatalysIdType::Uri
629+
CatalystIdType::Uri
633630
} else if uri.scheme() == Self::ADMIN_SCHEME {
634-
CatalysIdType::AdminUri
631+
CatalystIdType::AdminUri
635632
} else {
636633
return Err(errors::CatalystIdError::InvalidScheme);
637634
};
638635
(uri, r#type)
639636
} else {
640637
// It might be a RAW ID, so try and parse with the correct scheme.
641638
let uri = Uri::parse(format!("{}://{}", Self::SCHEME, s))?;
642-
let r#type = CatalysIdType::Id;
639+
let r#type = CatalystIdType::Id;
643640
(uri, r#type)
644641
}
645642
};
@@ -748,9 +745,9 @@ impl Display for CatalystId {
748745
f: &mut Formatter<'_>,
749746
) -> Result<(), std::fmt::Error> {
750747
match self.inner.r#type {
751-
CatalysIdType::Uri => write!(f, "{}://", Self::SCHEME.as_str())?,
752-
CatalysIdType::AdminUri => write!(f, "{}://", Self::ADMIN_SCHEME.as_str())?,
753-
CatalysIdType::Id => {},
748+
CatalystIdType::Uri => write!(f, "{}://", Self::SCHEME.as_str())?,
749+
CatalystIdType::AdminUri => write!(f, "{}://", Self::ADMIN_SCHEME.as_str())?,
750+
CatalystIdType::Id => {},
754751
}
755752

756753
let mut needs_at = false;

0 commit comments

Comments
 (0)