17 lines
424 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 {
return Err(format!("workspace id is empty or whitespace"));
}
Ok(Self(s))
}
}
impl AsRef<str> for UserWorkspace {
fn as_ref(&self) -> &str { &self.0 }
}