You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* 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
self.service_manager = self.service_manager.with_service(service).await;// The ServiceManagerBuilder itself will warn when adding a service multiple times
0 commit comments