Struct wicrs_server::user::User[][src]

pub struct User {
    pub id: ID,
    pub status: String,
    pub description: String,
    pub username: String,
    pub email: String,
    pub created: DateTime<Utc>,
    pub service: Service,
    pub in_hubs: Vec<ID>,
}

Represents a user of WICRS.

Fields

id: ID

ID of the user.

status: String

The user’s status.

description: String

The user’s description.

username: String

The user’s name.

email: String

The email address used by the user on their OAuth service.

created: DateTime<Utc>

Time of creation of the user in milliseconds from Unix Epoch.

service: Service

The OAuth service the user used to sign up.

in_hubs: Vec<ID>

A list of the hubs that the user is a member of.

Implementations

impl User[src]

pub async fn id(&self, ctx: &Context<'_>) -> Result<&ID>[src]

pub async fn status(&self, ctx: &Context<'_>) -> Result<&String>[src]

pub async fn description(&self, ctx: &Context<'_>) -> Result<&String>[src]

pub async fn username(&self, ctx: &Context<'_>) -> Result<&String>[src]

pub async fn email(&self, ctx: &Context<'_>) -> Result<&String>[src]

pub async fn created(&self, ctx: &Context<'_>) -> Result<&DateTime<Utc>>[src]

pub async fn service(&self, ctx: &Context<'_>) -> Result<&Service>[src]

pub async fn in_hubs(&self, ctx: &Context<'_>) -> Result<&Vec<ID>>[src]

impl User[src]

pub fn new(id: String, email: String, service: Service) -> Self[src]

Creates a new user and generates an ID by hashing the service used and the ID of the user according to that service.

pub fn to_generic(&self, requester_id: &ID) -> GenericUser[src]

Converts the standard user into a GenericUser, the hashed versions of the hub ID list also use the requester’s ID to avoid hash lists or rainbow tables being used.

pub fn join_hub(&mut self, hub: &mut Hub) -> Result[src]

Adds the user to the hub with the given ID, giving them the default permissions and making sure that they are not banned.

Errors

This function will return an error in the following situations, but is not limited to just these cases:

  • Thu hub does not exist.
  • The user is banned from the hub.
  • The user could not be added to the hub for any of the reasons outlined in Hub::user_join.
  • The hub failed to load for any of the reasons outlined in Hub::load.
  • The hub failed to save for any of the reasons outlined in Hub::save.

pub fn remove_hub(&mut self, hub_id: &ID) -> Result[src]

Removes the user from the hub with the given ID.

Errors

This function will return an error in the following situations, but is not limited to just these cases:

  • The user is not a member of the given hub.

pub async fn save(&self) -> Result[src]

Saves the user’s data to a file on the disk.

pub async fn load(id: &ID) -> Result<Self>[src]

Loads the data of the user with the given ID.

Errors

This function will return an error in the following situations, but is not limited to just these cases:

  • The user data file could not be found, probably means that the user does not exist.
  • The user data file was corrupt and or could not be deserialized properly.

pub async fn load_get_id(id: &str, service: &Service) -> Result<Self>[src]

Same as Self::load but first maps an OAuth ID and service name to a WICRS Server ID.

Arguments

  • id - the ID of the user on their selected OAuth service.
  • service - the user’s selected OAuth service.

Errors

This function will return an error in the same situations outlined by User::load

Trait Implementations

impl Clone for User[src]

impl ContainerType for User[src]

impl Debug for User[src]

impl<'de> Deserialize<'de> for User[src]

impl ObjectType for User[src]

impl OutputType for User[src]

impl PartialEq<User> for User[src]

impl Serialize for User[src]

impl StructuralPartialEq for User[src]

impl Type for User[src]

Auto Trait Implementations

impl RefUnwindSafe for User

impl Send for User

impl Sync for User

impl Unpin for User

impl UnwindSafe for User

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

impl<T> Downcast for T where
    T: Any

impl<T> DowncastSync for T where
    T: Any + Send + Sync

impl<T> From<T> for T[src]

impl<T> Fruit for T where
    T: Send + Downcast, 
[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> IntoResult<T> for T[src]

type Err = Infallible

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,