Struct Profile

Source
pub struct Profile {
Show 13 fields pub owners: Vec<Owner>, pub acc_id: Uuid, pub is_subscription: bool, pub is_manager: bool, pub is_staff: bool, pub owner_is_active: bool, pub account_is_active: bool, pub account_was_approved: bool, pub account_was_archived: bool, pub account_was_deleted: bool, pub verbose_status: Option<VerboseStatus>, pub licensed_resources: Option<LicensedResources>, pub tenants_ownership: Option<TenantsOwnership>, /* private fields */
}
Expand description

This is a re-exportation from the myc core to allow users to import both from myc-api instead of the myc-core. This object should be used over the application layer operations.

Fields§

§owners: Vec<Owner>§acc_id: Uuid

The account unique id

Such ID is related to the account primary-key instead of the owner primary key. In the case of the subscription accounts (accounts flagged with is_subscription) such ID should be propagated along the application flow.

§is_subscription: bool

If profile belongs to a subscription account

Subscription accounts should be used to manage legal entities. Only subscription accounts should receive guest accounts.

§is_manager: bool

If profile belongs to a manager account

Manager accounts should be used by users with elevated privileges inside the Mycelium platform. Such user should perform actions like create roles, guest-roles, guest default-user accounts to work into subscription accounts.

§is_staff: bool

If profile belongs to a staff account

Staff user has elevated roles into the application. Like managers, staff users has elevated privileges. Only staff user has permission to delegate other staffs.

§owner_is_active: bool

If the account owner is active

Profiles exists to abstract account privileges. If the profile is related to an inactive owner the profile could not perform any action. Only staff or manager user should perform the activation of such users.

§account_is_active: bool

If the account itself is inactive

When inactive accounts should not perform internal operations.

§account_was_approved: bool

If the account was approved after registration

New accounts should be approved by manager or staff users after their registration into the Mycelium platform. Case the approval was performed, this flag should be true.

§account_was_archived: bool

If the account was archived after registration

New accounts should be archived. After archived accounts should not be included at default filtering actions.

§account_was_deleted: bool

If the account was deleted after registration

New accounts should be deleted. After deleted accounts should not be included at default filtering actions.

§verbose_status: Option<VerboseStatus>

Indicate the profile status for humans

The profile status is composed of all account flags statuses composition. But it is not readable for humans. These struct attribute allows human users to understand the account status without read the flags, avoiding misinterpretation of this.

§licensed_resources: Option<LicensedResources>

Accounts guested to the current profile

Guest accounts delivers information about the guest account role and their respective permissions inside the host account. A single account should be several licenses into the same account.

§tenants_ownership: Option<TenantsOwnership>

Tenants which the profile has ownership

This field should be used to store the tenants that the profile has ownership. The ownership should be used to filter the licensed resources during system validations.

Implementations§

Source§

impl Profile

Source

pub fn new( owners: Vec<Owner>, acc_id: Uuid, is_subscription: bool, is_manager: bool, is_staff: bool, owner_is_active: bool, account_is_active: bool, account_was_approved: bool, account_was_archived: bool, account_was_deleted: bool, verbose_status: Option<VerboseStatus>, licensed_resources: Option<LicensedResources>, tenants_ownership: Option<TenantsOwnership>, ) -> Profile

Source

pub fn profile_string(&self) -> String

Source

pub fn profile_redacted(&self) -> String

Redacted profile string

Print the profile using the profile_string struct method and a list of owners, using the redacted_email structural method of the email field present in owners.

Source

pub fn get_owners_ids(&self) -> Vec<Uuid>

Source

pub fn has_admin_privileges(&self) -> bool

Source

pub fn has_admin_privileges_or_error(&self) -> Result<(), MappedErrors>

Source

pub fn on_tenant(&self, tenant_id: Uuid) -> Profile

Filter the licensed resources to the tenant

This method should be used to filter licensed resources to the tenant that the profile is currently working on.

Source

pub fn on_account(&self, account_id: Uuid) -> Profile

Filter the licensed resources to the account

This method should be used to filter licensed resources to the account that the profile is currently working on.

Source

pub fn with_tenant_ownership_or_error( &self, tenant_id: Uuid, ) -> Result<Profile, MappedErrors>

Filter the tenant ownership by the tenant

Source

pub fn with_system_accounts_access(&self) -> Profile

Filter the licensed resources to include only the standard system accounts

Source

pub fn with_read_access(&self) -> Profile

Filter the licensed resources to include only licenses with read access

Source

pub fn with_write_access(&self) -> Profile

Filter the licensed resources to include only licenses with write access

Source

pub fn with_roles<T>(&self, roles: Vec<T>) -> Profile
where T: ToString,

Source

pub fn get_ids_or_error(&self) -> Result<Vec<Uuid>, MappedErrors>

Trait Implementations§

Source§

impl Clone for Profile

Source§

fn clone(&self) -> Profile

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

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Profile

Source§

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

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

impl Default for Profile

Source§

fn default() -> Profile

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

impl<'de> Deserialize<'de> for Profile

Source§

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

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

impl PartialEq for Profile

Source§

fn eq(&self, other: &Profile) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Profile

Source§

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

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

impl ToSchema for Profile

Source§

fn name() -> Cow<'static, str>

Return name of the schema. Read more
Source§

fn schemas(schemas: &mut Vec<(String, RefOr<Schema>)>)

Implement reference utoipa::openapi::schema::Schemas for this type. Read more
Source§

impl StructuralPartialEq for Profile

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PartialSchema for T
where T: ComposeSchema + ?Sized,

Source§

fn schema() -> RefOr<Schema>

Return ref or schema of implementing type that can then be used to construct combined schemas.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Any for T
where T: Any,

Source§

impl<T> CloneAny for T
where T: Any + Clone,

Source§

impl<T> CloneAnySend for T
where T: Any + Send + Clone,

Source§

impl<T> CloneAnySendSync for T
where T: Any + Send + Sync + Clone,

Source§

impl<T> CloneAnySync for T
where T: Any + Sync + Clone,

Source§

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

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> Interface for T
where T: Any + Send + Sync,

Source§

impl<T> ModuleInterface for T
where T: Any + Send + Sync,