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:

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.

Returns a hub object with only the items that the given user is allowed to view. Only hides channels that the user does not have permission to view.

Errors

Possible errors are outlined by Hub::get_channels_for_user.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Resolves a field value and outputs it as a json value async_graphql::Value. Read more

Find the GraphQL entity with the given name from the parameter. Read more

Collect all the fields of the container that are queried in the selection set. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Resolve an output value to async_graphql::Value.

Serialize this value into the given Serde serializer. Read more

Type the name.

Create type information in the registry and return qualified typename.

Qualified typename.

Introspection type name Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

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

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

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

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Performs the conversion.

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

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.