sign_up.rs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. use crate::domain::{UserEmail, UserName, UserPassword};
  2. use flowy_derive::ProtoBuf;
  3. use std::convert::TryInto;
  4. #[derive(ProtoBuf, Default)]
  5. pub struct SignUpRequest {
  6. #[pb(index = 1)]
  7. pub email: String,
  8. #[pb(index = 2)]
  9. pub name: String,
  10. #[pb(index = 3)]
  11. pub password: String,
  12. }
  13. impl TryInto<SignUpParams> for SignUpRequest {
  14. type Error = String;
  15. fn try_into(self) -> Result<SignUpParams, Self::Error> {
  16. let email = UserEmail::parse(self.email)?;
  17. let name = UserName::parse(self.name)?;
  18. let password = UserPassword::parse(self.password)?;
  19. Ok(SignUpParams {
  20. email: email.0,
  21. name: name.0,
  22. password: password.0,
  23. })
  24. }
  25. }
  26. #[derive(ProtoBuf, Default)]
  27. pub struct SignUpParams {
  28. #[pb(index = 1)]
  29. pub email: String,
  30. #[pb(index = 2)]
  31. pub name: String,
  32. #[pb(index = 3)]
  33. pub password: String,
  34. }
  35. #[derive(ProtoBuf, Debug, Default)]
  36. pub struct SignUpResponse {
  37. #[pb(index = 1)]
  38. pub is_success: bool,
  39. }
  40. impl SignUpResponse {
  41. pub fn new(is_success: bool) -> Self { Self { is_success } }
  42. }