Skip to content
This repository was archived by the owner on Aug 15, 2025. It is now read-only.

Commit db68514

Browse files
committed
feat: make FederationId strongly typed (remove inner String fields)
1 parent 7dc9df5 commit db68514

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/types/federation_id.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use x509_cert::ext::pkix::name::DirectoryString;
1212
use x509_cert::name::{RdnSequence, RelativeDistinguishedName};
1313

1414
use crate::errors::{ConstraintError, ERR_MSG_FEDERATION_ID_REGEX, InvalidInput};
15+
use crate::types::local_name::LocalName;
1516
use crate::{Constrained, OID_RDN_DOMAIN_COMPONENT, OID_RDN_UID};
1617

1718
/// The regular expression for a valid `FederationId`.
@@ -109,9 +110,9 @@ impl TryFrom<DomainName> for RdnSequence {
109110
/// A `FederationId` is a globally unique identifier for an actor in the context of polyproto.
110111
pub struct FederationId {
111112
/// Must be unique on each instance.
112-
pub(crate) local_name: String,
113+
pub(crate) local_name: LocalName,
113114
/// Includes top-level domain, second-level domain and other subdomains. Address which the actors' home server can be reached at.
114-
pub(crate) domain_name: String,
115+
pub(crate) domain_name: DomainName,
115116
}
116117

117118
impl FederationId {
@@ -131,8 +132,8 @@ impl FederationId {
131132
let local_name = id[0..separator_position].to_string();
132133
let domain_name = id[separator_position + 1..].to_string();
133134
let fid = Self {
134-
local_name,
135-
domain_name,
135+
local_name: LocalName::new(&local_name)?,
136+
domain_name: DomainName::new(&domain_name)?,
136137
};
137138
fid.validate(None)?;
138139
Ok(fid)

0 commit comments

Comments
 (0)