Struct wicrs_server::hub::Hub [−][src]
pub struct Hub { pub channels: HashMap<ID, Channel>, pub members: HashMap<String, HubMember>, pub bans: HashSet<String>, pub mutes: HashSet<String>, pub description: String, pub owner: String, pub groups: HashMap<ID, PermissionGroup>, pub default_group: ID, pub name: String, pub id: ID, pub created: DateTime<Utc>, }
Expand description
Represents a group of users, permission groups and channels.
Fields
channels: HashMap<ID, Channel>
Map of channels to their IDs.
members: HashMap<String, HubMember>
Map of hub members to their corresponding user’s IDs.
bans: HashSet<String>
List of IDs of all users that are banned from the hub.
mutes: HashSet<String>
List of IDs of all the users who cannot send any messages in the hub.
description: String
Description of the hub.
owner: String
ID of the user who owns the hub, also the creator.
groups: HashMap<ID, PermissionGroup>
Map of permission groups to their IDs.
default_group: ID
ID of the default permission group to be given to new hub members, for now this is always the “everyone” group.
name: String
Name of the hub.
id: ID
ID of the hub.
created: DateTime<Utc>
Time the hub was created in milliseconds since Unix Epoch.
Implementations
Creates a new hub given the ID of the user who should be the owner, the name and the ID the hub should have.
Creates a new channel while checking that the given user has permission to do so.
Errors
This function will return an error in the following situations, but is not limited to just these cases:
- Failed to pass
check_name_validity
. - The user it not in the hub.
- The user does not have permission create new channels.
- Any of the reasons outlined in
Channel::create_dir
.
Gets a reference to the channel. Returns an error if the channel could not be found or the user did not have permission to view the channel.
Gets a mutable reference to the channel. Returns an error if the channel could not be found or the user did not have permission to view the channel.
Checks if the user with the given ID is in the hub.
Checks if the user with the given ID is in the hub, if not in hub also checks if banned.
Gets a reference to the hub member, returns an error if the member could not be found.
Gets a mutable reference to the hub member, returns an error if the member could not be found.
Changes the description of a channel while checking that the given user has permission to do so.
Errors
This function will return an error in the following situations, but is not limited to just these cases:
- Description is bigger than
crate::MAX_DESCRIPTION_SIZE
. - The user it not in the hub.
- The user does not have permission to view the channel.
- The user does not have permission to configure the channel.
- The channel does not exist.
Renames a channel while checking that the given user has permission to do so.
Errors
This function will return an error in the following situations, but is not limited to just these cases:
- Failed to pass
check_name_validity
. - The user it not in the hub.
- The user does not have permission to view the channel.
- The user does not have permission to configure the channel.
- The channel does not exist.
Deletes a channel while checking that the given user has permission to do so.
Errors
This function will return an error in the following situations, but is not limited to just these cases:
- The user is not in the hub.
- The channel does not exist.
- THe user does not have permission to view the channel.
- The user does not have permission to delete the channel.
Gets the file path to be used for storing the hub’s data.
Gets the path of the directory in which channel folders should be stored.
Saves the hub’s data to disk.
Errors
This function will return an error in the following situations, but is not limited to just these cases:
- The hub data could not be serialized.
- The hub info folder does not exist and could not be created.
- The data could not be written to the disk.
Loads a hub’s data given its ID.
Errors
This function will return an error in the following situations, but is not limited to just these cases:
- There is no hub with that ID.
- The hub’s data file was corrupt and could not be deserialized.
Adds a user to a hub, creating and returning the resulting hub member.
Errors
This function will return an error in the following situations, but is not limited to just this case:
- The default permission group could not be found.
Removes the given user from the hub.
Errors
This function will return an error in the following situations, but is not limited to just these cases:
- The user is not in the hub.
- One of the permission groups the user was in could not be found in the hub.
Kicks the given user from the hub, forcing them to leave.
Errors
This function will return an error in the following situations, but is not limited to just these cases:
- The user could not be removed from the hub for any of the reasons outlined in
Hub::user_leave
. - The user’s data failed to load for any of the reasons outlined in [
User::load
]. - The user’s data failed to save for any of the reasons outlined in [
User::save
].
Kicks the given user and adds them to the banned list.
Errors
Possible errors outlined by Hub::kick_user
.
Removes the given user from the banned lis.
Adds the given user to the mute list, preventing them from sending messages.
Removes the given user from the mutes list, allowing them to send messages.
Gets a list of the channels that the given user has permission to view.
Errors
This function will only return an error if the given user is not in the hub.
Trait Implementations
fn resolve_field<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 Context<'life2>
) -> Pin<Box<dyn Future<Output = ServerResult<Option<Value>>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
[src]
fn resolve_field<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 Context<'life2>
) -> Pin<Box<dyn Future<Output = ServerResult<Option<Value>>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
[src]Resolves a field value and outputs it as a json value async_graphql::Value
. Read more
fn find_entity<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
ctx: &'life1 Context<'life2>,
params: &'life3 Value
) -> Pin<Box<dyn Future<Output = ServerResult<Option<Value>>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
[src]
fn find_entity<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
ctx: &'life1 Context<'life2>,
params: &'life3 Value
) -> Pin<Box<dyn Future<Output = ServerResult<Option<Value>>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
[src]Find the GraphQL entity with the given name from the parameter. Read more
fn collect_all_fields(
&'a self,
ctx: &ContextBase<'a, &'a Positioned<SelectionSet>>,
fields: &mut Fields<'a>
) -> Result<(), ServerError> where
Self: Send + Sync,
[src]
fn collect_all_fields(
&'a self,
ctx: &ContextBase<'a, &'a Positioned<SelectionSet>>,
fields: &mut Fields<'a>
) -> Result<(), ServerError> where
Self: Send + Sync,
[src]Collect all the fields of the container that are queried in the selection set. Read more
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]Deserialize this value from the given Serde deserializer. Read more
fn resolve<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
ctx: &'life1 ContextSelectionSet<'life2>,
_field: &'life3 Positioned<Field>
) -> Pin<Box<dyn Future<Output = ServerResult<Value>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
[src]
fn resolve<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
ctx: &'life1 ContextSelectionSet<'life2>,
_field: &'life3 Positioned<Field>
) -> Pin<Box<dyn Future<Output = ServerResult<Value>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
[src]Resolve an output value to async_graphql::Value
.
Create type information in the registry and return qualified typename.
Qualified typename.
Introspection type name Read more
Auto Trait Implementations
impl RefUnwindSafe for Hub
impl UnwindSafe for Hub
Blanket Implementations
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
Convert Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
type Output = T
type Output = T
Should always be Self
pub fn vzip(self) -> V