aboutsummaryrefslogtreecommitdiff
path: root/src/cache
Commit message (Collapse)AuthorAgeFilesLines
* Fix doc links with no anchorZeyla Hellyer2018-07-111-1/+3
|
* Add a message cache API (#345)zeyla2018-07-092-1/+126
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds an API for message caching. By default this caches 0 messages per channel. This can be customized when instantiating: ```rust use serenity::cache::{Cache, Settings}; let mut settings = Settings::new(); // Cache 10 messages per channel. settings.max_messages(10); let cache = Cache::new_with_settings(settings); ``` After instantiation: ```rust use serenity::cache::Cache; let mut cache = Cache::new(); cache.settings_mut().max_messages(10); ``` And during runtime through the global cache: ```rust use serenity::CACHE; CACHE.write().settings_mut().max_messages(10); ```
* Make the Cache Update API public (#344)zeyla2018-07-052-4/+118
| | | | | | | | | | | This commit makes the Cache Update API public, allowing users to manually update the cache, as well as implementing the caching API on their own types to work with mutating the cache. The motivation for this indirectly comes from a message cache: if a user has multiple processes that can receive cache updates (either splitting a bot's shards into multiple processes or other processes like web panels or pub/sub channels), then this will allow them to easily mutate the cache and feed all types implementing the CacheUpdate trait into `Cache::update`.
* Monomorphize all functionsZeyla Hellyer2018-07-041-11/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | This commit monomorphizes all functions, turning functions like: ```rust fn foo<T: Into<Bar>>(baz: T) { baz = baz.into(); // function here } ``` Into functions like: ```rust fn foo<T: Into<Bar>>(baz: T) { _foo(baz.into()) } fn _foo(baz: Bar) { // function here } ``` This avoids binary bloat and improves build times, by reducing the amount of code duplication.
* Remove extraneous spaces at the end of linesZeyla Hellyer2018-06-171-2/+2
|
* Refactor imports/exports to use nested groups and better formattingacdenisSK2018-03-291-4/+9
|
* Fix broken docs links caused by model mod changesZeyla Hellyer2018-01-311-38/+38
| | | | | Fix broken links caused by the `model` module changes in v0.5.0, which split up the module into sub-modules for better organization.
* Break up the model moduleZeyla Hellyer2017-12-161-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `model` module has historically been one giant module re-exporting all of the model types, which is somewhere around 100 types. This can be a lot to look at for a new user and somewhat overwhelming, especially with a large number of fine-grained imports from the module. The module is now neatly split up into submodules, mostly like it has been internally since the early versions of the library. The submodules are: - application - channel - error - event - gateway - guild - id - invite - misc - permissions - prelude - user - voice - webhook Each submodule contains types that are "owned" by the module. For example, the `guild` submodule contains, but not limited to, Emoji, AuditLogsEntry, Role, and Member. `channel` contains, but not limited to, Attachment, Embed, Message, and Reaction. Upgrade path: Instead of glob importing the models via `use serenity::model::*;`, instead glob import via the prelude: ```rust use serenity::model::prelude::*; ``` Instead of importing from the root model module: ```rust use serenity::model::{Guild, Message, OnlineStatus, Role, User}; ``` instead import from the submodules like so: ```rust use serenity::model::channel::Message; use serenity::model::guild::{Guild, Role}; use serenity::model::user::{OnlineStatus, User}; ```
* Re-order use statements alphabeticallyZeyla Hellyer2017-11-111-4/+4
|
* Fix doc-testsacdenisSK2017-11-081-5/+5
|
* Merge v0.4.3acdenisSK2017-11-041-18/+44
|\
| * Fix doctests for a variety of feature targetsZeyla Hellyer2017-11-011-2/+4
| |
| * Fix no-client cache testsZeyla Hellyer2017-11-011-11/+33
| | | | | | | | | | There were a few doctests in the cache module that relied on the client module, so instead feature-gate the doctests.
* | Make the Client return a ResultZeyla Hellyer2017-11-031-2/+6
| | | | | | | | | | | | | | | | The client now returns a Result in preparation of a future commit. Upgrade path: Handle the case of an error via pattern matching, or unwrap the Result.
* | Remove `on_` prefix to EventHandler tymethodsZeyla Hellyer2017-10-221-3/+3
| | | | | | | | | | It was voted that the `on_` prefix is unnecessary, so these have been dropped.
* | Update to account for changes made in 0.4.1acdenisSK2017-10-141-3/+3
|\|
| * Fix clippy lintsZeyla Hellyer2017-10-111-3/+3
| |
| * Generate `Default` for CurrentUser and use it in `Cache::default`acdenisSK2017-10-081-10/+1
| |
| * Revert "Use the de-generification trick."acdenisSK2017-10-031-43/+9
| | | | | | | | Makes the compiliation time just a bit worse
| * Use the de-generification trick.acdenisSK2017-10-021-9/+43
| | | | | | | | Fixes #168
* | Switch to parking_lot::{Mutex, RwLock}Zeyla Hellyer2017-10-101-29/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Switch to the `parking_lot` crate's implementations of `std::sync::Mutex` and `std::sync::RwLock`, which are more efficient. A writeup on why `parking_lot` is more efficient can be read here: <https://github.com/Amanieu/parking_lot> Upgrade path: Modify `mutex.lock().unwrap()` usage to `mutex.lock()` (not needing to unwrap or handle a result), and `rwlock.read().unwrap()`/`rwlock.write().unwrap()` usage to `rwlock.read()` and `rwlock.write()`. For example, modify: ```rust use serenity::CACHE; println!("{}", CACHE.read().unwrap().user.id); ``` to: ```rust use serenity::CACHE; println!("{}", CACHE.read().user.id); ```
* | Generate `Default` for CurrentUser and use it in `Cache::default`acdenisSK2017-10-091-10/+1
| |
* | Revert "Use the de-generification trick."acdenisSK2017-10-091-43/+9
| | | | | | | | Makes the compiliation time just a bit worse
* | Use the de-generification trick.acdenisSK2017-10-091-9/+43
|/ | | | Fixes #168
* Apply rustfmtZeyla Hellyer2017-09-181-3/+3
|
* Fix compiles of a variety of feature combinationsZeyla Hellyer2017-09-181-0/+1
| | | | | This fixes compilation errors and warnings when compiling a mixture of non-default feature targets.
* Don't clone in Cache::all_guilds/private_channelsZeyla Hellyer2017-09-141-5/+3
| | | | We don't need to clone the Vec, if the user needs to they can.
* Put the cloning at a later stageacdenisSK2017-09-141-2/+2
|
* Revamp `CacheEventsImpl`acdenisSK2017-09-123-517/+14
|
* Handle channel category deletionZeyla Hellyer2017-09-091-14/+16
|
* Apply rustfmt + fix testsZeyla Hellyer2017-09-092-5/+11
|
* Implement categoriesacdenisSK2017-09-092-0/+18
|
* Add ability to play DCA and Opus files. (#148)Maiddog2017-08-272-58/+68
|
* Revamp `RwLock` usage in the libacdenisSK2017-08-242-117/+93
| | | | Also not quite sure if they goofed rustfmt or something, but its changes it did were a bit bizarre.
* Apply rustfmtZeyla Hellyer2017-08-182-92/+73
|
* ClippyacdenisSK2017-08-191-1/+1
|
* Don't do any other fuzz about private channels if they're already in the cacheacdenisSK2017-08-111-0/+4
|
* Put `update_user_entry` back into the cacheacdenisSK2017-08-112-14/+12
| | | | Not really related to the events by any means
* Split event handling in the cache to a traitacdenisSK2017-08-102-473/+544
| | | | note: This trait might become like `framework::Framework` in the future.
* Remove uneccessary mapacdenisSK2017-08-041-2/+2
|
* Change the config a bit, and a few nitpicksacdenisSK2017-07-271-34/+32
|
* rustfmtacdenisSK2017-07-271-104/+130
|
* Remove the deprecated functionsacdenisSK2017-07-111-67/+0
| | | | It's already been enough time for people to migrate
* Actually, use `unreachable!` instead of `panic!`acdenisSK2017-07-071-1/+1
|
* Apply the new api change for dms in botsacdenisSK2017-07-071-35/+19
|
* Fix doc testsacdenisSK2017-07-021-40/+52
|
* Docs fixesmei2017-06-271-49/+11
|
* Switch from #[doc(hidden)] to pub(crate)alex2017-06-141-47/+25
| | | | | | Switch from using `#[doc(hidden)]` to hide some internal functions to `pub(crate)`. The library now requires rustc 1.18.
* Make Member::guild_id non-optionalZeyla Hellyer2017-06-131-1/+1
| | | | All codepaths result in Some value, so it doesn't need to be optional.
* Deprecate Client::login, add Client::newZeyla Hellyer2017-06-061-3/+3
|