mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-08-26 09:42:32 +00:00
17 lines
391 B
Rust
17 lines
391 B
Rust
![]() |
#[derive(Debug)]
|
||
|
pub struct UserId(pub String);
|
||
|
|
||
|
impl UserId {
|
||
|
pub fn parse(s: String) -> Result<UserId, String> {
|
||
|
let is_empty_or_whitespace = s.trim().is_empty();
|
||
|
if is_empty_or_whitespace {
|
||
|
return Err(format!("user id is empty or whitespace"));
|
||
|
}
|
||
|
Ok(Self(s))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl AsRef<str> for UserId {
|
||
|
fn as_ref(&self) -> &str { &self.0 }
|
||
|
}
|