aboutsummaryrefslogtreecommitdiff
path: root/src/utils/builder/edit_profile.rs
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2017-05-22 17:02:00 -0700
committerZeyla Hellyer <[email protected]>2017-05-22 17:02:00 -0700
commit9969be60cf320797c37b317da24d9a08fd5eafa5 (patch)
treef27bf7a57af95bbc11990b1edcea9cca99276964 /src/utils/builder/edit_profile.rs
parentReasonably derive Debug on items (diff)
downloadserenity-9969be60cf320797c37b317da24d9a08fd5eafa5.tar.xz
serenity-9969be60cf320797c37b317da24d9a08fd5eafa5.zip
Restructure modules
Modules are now separated into a fashion where the library can be used for most use cases, without needing to compile the rest. The core of serenity, with no features enabled, contains only the struct (model) definitions, constants, and prelude. Models do not have most functions compiled in, as that is separated into the `model` feature. The `client` module has been split into 3 modules: `client`, `gateway`, and `http`. `http` contains functions to interact with the REST API. `gateway` contains the Shard to interact with the gateway, requiring `http` for retrieving the gateway URL. `client` requires both of the other features and acts as an abstracted interface over both the gateway and REST APIs, handling the event loop. The `builder` module has been separated from `utils`, and can now be optionally compiled in. It and the `http` feature are required by the `model` feature due to a large number of methods requiring access to them. `utils` now contains a number of utilities, such as the Colour struct, the `MessageBuilder`, and mention parsing functions. Each of the original `ext` modules are still featured, with `cache` not requiring any feature to be enabled, `framework` requiring the `client`, `model`, and `utils`, and `voice` requiring `gateway`. In total the features and their requirements are: - `builder`: none - `cache`: none - `client`: `gateway`, `http` - `framework`: `client`, `model`, `utils` - `gateway`: `http` - `http`: none - `model`: `builder`, `http` - `utils`: none - `voice`: `gateway` The default features are `builder`, `cache`, `client`, `framework`, `gateway`, `model`, `http`, and `utils`. To help with forwards compatibility, modules have been re-exported from their original locations.
Diffstat (limited to 'src/utils/builder/edit_profile.rs')
-rw-r--r--src/utils/builder/edit_profile.rs93
1 files changed, 0 insertions, 93 deletions
diff --git a/src/utils/builder/edit_profile.rs b/src/utils/builder/edit_profile.rs
deleted file mode 100644
index 64bd7a9..0000000
--- a/src/utils/builder/edit_profile.rs
+++ /dev/null
@@ -1,93 +0,0 @@
-use ::internal::prelude::*;
-
-/// A builder to edit the current user's settings, to be used in conjunction
-/// with [`Context::edit_profile`].
-///
-/// [`Context::edit_profile`]: ../../client/struct.Context.html#method.edit_profile
-#[derive(Clone, Debug, Default)]
-pub struct EditProfile(pub JsonMap);
-
-impl EditProfile {
- /// Sets the avatar of the current user. `None` can be passed to remove an
- /// avatar.
- ///
- /// A base64-encoded string is accepted as the avatar content.
- ///
- /// # Examples
- ///
- /// A utility method - [`utils::read_image`] - is provided to read an
- /// image from a file and return its contents in base64-encoded form:
- ///
- /// ```rust,ignore
- /// use serenity::utils;
- ///
- /// // assuming a `context` has been bound
- ///
- /// let base64 = utils::read_image("./my_image.jpg")
- /// .expect("Failed to read image");
- ///
- /// let _ = context.edit_profile(|profile| {
- /// profile.avatar(Some(&base64))
- /// });
- /// ```
- ///
- /// [`utils::read_image`]: ../fn.read_image.html
- pub fn avatar(mut self, avatar: Option<&str>) -> Self {
- let avatar = avatar.map_or(Value::Null, |x| Value::String(x.to_owned()));
-
- self.0.insert("avatar".to_owned(), avatar);
-
- self
- }
-
- /// Modifies the current user's email address.
- ///
- /// Note that when modifying the email address, the current password must
- /// also be [provided].
- ///
- /// No validation is performed on this by the library.
- ///
- /// **Note**: This can only be used by user accounts.
- ///
- /// [provided]: #method.password
- pub fn email(mut self, email: &str) -> Self {
- self.0.insert("email".to_owned(), Value::String(email.to_owned()));
-
- self
- }
-
- /// Modifies the current user's password.
- ///
- /// Note that when modifying the password, the current password must also be
- /// [provided].
- ///
- /// [provided]: #method.password
- pub fn new_password(mut self, new_password: &str) -> Self {
- self.0.insert("new_password".to_owned(), Value::String(new_password.to_owned()));
-
- self
- }
-
- /// Used for providing the current password as verification when
- /// [modifying the password] or [modifying the associated email address].
- ///
- /// [modifying the password]: #method.new_password
- /// [modifying the associated email address]: #method.email
- pub fn password(mut self, password: &str) -> Self {
- self.0.insert("password".to_owned(), Value::String(password.to_owned()));
-
- self
- }
-
- /// Modifies the current user's username.
- ///
- /// When modifying the username, if another user has the same _new_ username
- /// and current discriminator, a new unique discriminator will be assigned.
- /// If there are no available discriminators with the requested username,
- /// an error will occur.
- pub fn username(mut self, username: &str) -> Self {
- self.0.insert("username".to_owned(), Value::String(username.to_owned()));
-
- self
- }
-}