Struct b3_users::data::user::UserData

source ·
pub struct UserData {
    pub name: String,
    pub email: String,
    pub balance: u128,
    pub addresses: Vec<UserAddressData>,
    pub settings: HashMap<String, UserDataSettingValue>,
    /* private fields */
}

Fields§

§name: String§email: String§balance: u128§addresses: Vec<UserAddressData>§settings: HashMap<String, UserDataSettingValue>

Implementations§

source§

impl UserData

source

pub fn new(user_args: UserDataArgs, address_args: UserAddressArgs) -> Self

source

pub fn update(&mut self, args: UserDataArgs) -> UserDataArgs

Updates the user’s data based on the provided UserDataArgs struct. Only updates fields that are set to Some(value) in the options.

source

pub fn create_address( &mut self, args: UserAddressArgs ) -> Result<UserAddressData, UserStateError>

Adds a new address for the user with the given key and address data. Returns an error if the key already exists.

source

pub fn get_new_key(&self) -> Result<usize, UserStateError>

New derivation path based on the number of addresses created. Returns the derivation path as a vector of bytes.

source

pub fn get_key_is_valid(&self, key: usize) -> Result<(), UserStateError>

Retrieves the derivation path for the given key. Returns the derivation path as a vector of bytes.

source

pub fn get_address(&self, key: usize) -> Result<UserAddressData, UserStateError>

Retrieves an address by key for the user. Returns the address data if the key is found, or error if the key was not found.

source

pub fn get_address_mut( &mut self, key: usize ) -> Result<&mut UserAddressData, UserStateError>

Retrieves a mutable reference to the address by key for the user. Returns the address data if the key is found, or error if the key was not found.

source

pub fn get_addresses(&self) -> &Vec<UserAddressData>

Retrieves all the addresses created by the user. Returns a Vec of UserAddressData objects.

source

pub fn set_password(&mut self, password: &str) -> Result<(), UserStateError>

Sets the password for the user.

source

pub fn check_password(&self, password: &str) -> Result<bool, UserStateError>

Checks if the provided password matches the user’s password.

source

pub fn get_setting( &self, key: &str ) -> Result<UserDataSettingValue, UserStateError>

Retrieves the user’s setting. Returns the value if the key is found, or None if the key was not found.

source

pub fn get_setting_mut( &mut self, key: &str ) -> Result<&mut UserDataSettingValue, UserStateError>

Retrieves a mutable reference to the user’s setting. Returns the value if the key is found, or None if the key was not found.

source

pub fn get_settings(&self) -> &HashMap<String, UserDataSettingValue>

Retrieves a setting value by key for the user. Returns the value if the key is found, or None if the key was not found.

source

pub fn set_setting(&mut self, key: String, value: UserDataSettingValue)

Sets a setting key-value pair for the user.

source

pub fn remove_setting(&mut self, key: &str) -> Result<bool, UserStateError>

Removes a setting key for the user. Returns the removed value if it existed, or None if the key was not found.

source

pub fn update_settings( &mut self, new_settings: HashMap<String, UserDataSettingValue> )

Updates all the settings for the user with the new settings.

Trait Implementations§

source§

impl CandidType for UserData

source§

fn _ty() -> Type

source§

fn id() -> TypeId

source§

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

source§

fn ty() -> Type

source§

impl Clone for UserData

source§

fn clone(&self) -> UserData

Returns a copy 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 UserData

source§

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

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

impl Default for UserData

source§

fn default() -> UserData

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for UserData

source§

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

Deserialize this value from the given Serde deserializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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