CreateUserRequest

Struct CreateUserRequest 

Source
pub struct CreateUserRequest {
    pub id: Uuid,
    pub telegram_id: Option<i64>,
    pub email: Option<String>,
    pub phone: Option<String>,
}
Expand description

Request to create a new user.

Contains the minimal data required to create a user record. Additional profile data can be added later via UpdateProfileRequest.

§Fields

FieldTypeDescription
idUuidPre-generated user ID (auto-generated if not provided)
telegram_idOption<i64>Telegram user ID
emailOption<String>Email address
phoneOption<String>Phone number

§Validation

  • telegram_id: Must be positive (≥ 1)
  • email: Must be valid email format

§Examples

use revelation_user::CreateUserRequest;
use validator::Validate;

// Valid request
let req = CreateUserRequest::telegram(123456789);
assert!(req.validate().is_ok());

// Manual construction
let req = CreateUserRequest {
    id:          uuid::Uuid::now_v7(),
    telegram_id: Some(123),
    email:       None,
    phone:       None
};

Fields§

§id: Uuid

Pre-generated user ID.

Defaults to a new UUIDv7 if not provided during deserialization.

§telegram_id: Option<i64>

Telegram user ID from bot callback.

Must be a positive integer.

§email: Option<String>

Email address from email authentication.

Must be a valid email format.

§phone: Option<String>

Phone number from phone authentication.

Should be in E.164 format (e.g., +14155551234).

Implementations§

Source§

impl CreateUserRequest

Source

pub fn telegram(telegram_id: i64) -> Self

Create request for Telegram authentication.

§Arguments
  • telegram_id - The Telegram user ID from login callback
§Examples
use revelation_user::CreateUserRequest;

let req = CreateUserRequest::telegram(123456789);

assert_eq!(req.telegram_id, Some(123456789));
assert!(req.email.is_none());
assert!(req.phone.is_none());
Source

pub fn email(email: impl Into<String>) -> Self

Create request for email authentication.

§Arguments
  • email - The verified email address
§Examples
use revelation_user::CreateUserRequest;

let req = CreateUserRequest::email("user@example.com");

assert_eq!(req.email.as_deref(), Some("user@example.com"));
assert!(req.telegram_id.is_none());
Source

pub fn phone(phone: impl Into<String>) -> Self

Create request for phone authentication.

§Arguments
  • phone - The phone number in E.164 format
§Examples
use revelation_user::CreateUserRequest;

let req = CreateUserRequest::phone("+14155551234");

assert_eq!(req.phone.as_deref(), Some("+14155551234"));

Trait Implementations§

Source§

impl Clone for CreateUserRequest

Source§

fn clone(&self) -> CreateUserRequest

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CreateUserRequest

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for CreateUserRequest

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for CreateUserRequest

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Validate for CreateUserRequest

Source§

impl<'v_a> ValidateArgs<'v_a> for CreateUserRequest

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,