Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Kitt3120/lum Loading
base: f059ed0
Choose a base ref
...
head repository: Kitt3120/lum Loading
compare: 7bad3ad
Choose a head ref
  • 1 commit
  • 7 files changed
  • 1 contributor

Commits on Jan 7, 2024

  1. Refactor service framework (#25)

    * Service framework improvements
    
     - Way better handling of mutable/immutable attributes
     - Less Mutexes
     - Better handling of passing references through the service framework's API
     - Reimplement get_service accepting a TypeId as a generic parameter for easier usage
     - Reimplement status_map and status_tree as a result of the above adaptations, resulting in way simpler versions
    
    * More service framework improvements
    
     - Replace all Mutexes with RwLock
     - Remove status_map method of ServiceManager
     - Services vector in ServiceManager now wraps the Service trait objects in a RwLock to potentially make them available mutably through the public API of ServiceManager
    
    * Implement get_service<T> method
    
     - Add downcast-rs crate
     - Implement get_service<T> method of ServiceManager
    
    Had to use unsafe Rust for this. Tried it with safe Rust for 3 days and couldn't do it. With unsafe Rust, it's very easy. It's also still kinda safe, as the crash case is checked and prevented before going into the unsafe block.
    
    * Finish refactor of service framework
    
     - ServiceManager now holds an Arc to itself
     - Self-Arc is now passed to services when initializing them, so they can access other services and copy Arcs to those for themselves
     - Implement SetLock<T> struct which is a wrapper around Option<T> for lazy-initialization
     - ServiceManagerBuilder handles the creation and injection of the Self-Arc of ServiceManager. That's why the build() method is now async and the From trait had to be removed. The From trait cannot be implemented async.
     - To keep everything consistent, the From trait has also been removed from the BotBuilder and the build() method becase async.
    
    * Adapt Discord service
    
     - Adapt Discord service to new service framework and SetLock type
    Kitt3120 committed Jan 7, 2024
    Configuration menu
    Copy the full SHA
    7bad3ad View commit details
    Browse the repository at this point in the history
Loading