19 lines
439 B
Rust
Raw Normal View History

#[derive(Debug)]
pub struct UserWorkspace(pub String);
impl UserWorkspace {
pub fn parse(s: String) -> Result<UserWorkspace, String> {
let is_empty_or_whitespace = s.trim().is_empty();
if is_empty_or_whitespace {
2021-11-27 19:19:41 +08:00
return Err("workspace id is empty or whitespace".to_string());
}
Ok(Self(s))
}
}
impl AsRef<str> for UserWorkspace {
2022-01-23 12:14:00 +08:00
fn as_ref(&self) -> &str {
&self.0
}
}