doc_id.rs 393 B

123456789101112131415161718
  1. #[derive(Debug)]
  2. pub struct DocumentIdentify(pub String);
  3. impl DocumentIdentify {
  4. pub fn parse(s: String) -> Result<DocumentIdentify, String> {
  5. if s.trim().is_empty() {
  6. return Err("Doc id can not be empty or whitespace".to_string());
  7. }
  8. Ok(Self(s))
  9. }
  10. }
  11. impl AsRef<str> for DocumentIdentify {
  12. fn as_ref(&self) -> &str {
  13. &self.0
  14. }
  15. }