Expand description
Traits for implementing a InMemoryCache with custom structs.
By default, the cache uses widely compatible default types that contain almost all fields that are present in the Discord API. Fields that are never used by the user will result in excess memory usage that will especially matter to big bots with a lot of cached data.
The traits in this module allow creating custom cached representations of Discord
API models compatible with the InMemoryCache. They may be mixed with the default
types provided by twilight, which also implement these traits.
However, as Discord extends its API models with new fields or changes the types, the trait definitions may change in minor crate releases to allow twilight to keep up with upstream API changes. Since not all fields are required for caching logic, this is not very likely to happen on a regular basis, but should be considered when deciding to opt for writing custom types.
Many traits require getters for certain types, which means they are used for caching
logic. However, users generally won’t have to store all the fields. It is possible
to return None or empty arrays on most of the methods if the data that is accessed
is not stored in the custom implementation.
Traits§
- Cacheable
Channel - Trait for a generic cached representation of a [
Channel]. - Cacheable
Current User - Trait for a generic cached representation of a [
CurrentUser]. - Cacheable
Emoji - Trait for a generic cached representation of a [
Emoji]. - Cacheable
Guild - Trait for a generic cached representation of a [
Guild]. - Cacheable
Guild Integration - Trait for a generic cached representation of a [
GuildIntegration]. - Cacheable
Guild Scheduled Event - Trait for a generic cached representation of a [
GuildScheduledEvent]. - Cacheable
Member - Trait for a generic cached representation of a [
Member]. - Cacheable
Message - Trait for a generic cached representation of a [
Message]. - Cacheable
Models - Super-trait for the generic cached representations of Discord API models.
- Cacheable
Presence - Trait for a generic cached representation of a [
Presence]. - Cacheable
Role - Trait for a generic cached representation of a [
Role]. - Cacheable
Stage Instance - Trait for a generic cached representation of a [
StageInstance]. - Cacheable
Sticker - Trait for a generic cached representation of a [
Sticker]. - Cacheable
User - Trait for a generic cached representation of a [
User]. - Cacheable
Voice State - Trait for a generic cached representation of a [
VoiceState].