app_desc.rs 410 B

12345678910111213141516171819
  1. use unicode_segmentation::UnicodeSegmentation;
  2. #[derive(Debug)]
  3. pub struct AppDesc(pub String);
  4. impl AppDesc {
  5. pub fn parse(s: String) -> Result<AppDesc, String> {
  6. if s.graphemes(true).count() > 1024 {
  7. return Err("Workspace description too long".to_string());
  8. }
  9. Ok(Self(s))
  10. }
  11. }
  12. impl AsRef<str> for AppDesc {
  13. fn as_ref(&self) -> &str {
  14. &self.0
  15. }
  16. }