Struct wicrs_server::user::User [−][src]
Represents a user, keeps track of which accounts it owns and their metadata.
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: u128
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 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 async 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 Debug for User
[src]
impl<'de> Deserialize<'de> for User
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl PartialEq<User> for User
[src]
impl Serialize for User
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl StructuralPartialEq 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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> Downcast for T where
T: Any,
T: Any,
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn as_any(&self) -> &(dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
impl<T> DowncastSync for T where
T: Any + Send + Sync,
T: Any + Send + Sync,
impl<T> From<T> for T
[src]
impl<T> Fruit for T where
T: Send + Downcast,
[src]
T: Send + Downcast,
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> IntoResult<T> for T
[src]
type Err = Infallible
pub fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
[src]
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
U: TryFrom<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,