(
state: &Rc<RefCell<OpState>>,
f: impl Future<Output = Result<T, AnyError>> + Send + 'static,
)
| 271 | } |
| 272 | |
| 273 | pub async fn discord_request_any<T: Send + Sync + 'static>( |
| 274 | state: &Rc<RefCell<OpState>>, |
| 275 | f: impl Future<Output = Result<T, AnyError>> + Send + 'static, |
| 276 | ) -> Result<T, AnyError> { |
| 277 | let rt_handle = { |
| 278 | let state = state.borrow(); |
| 279 | let rt_ctx: &RuntimeContext = state.borrow(); |
| 280 | rt_ctx.main_tokio_runtime.clone() |
| 281 | }; |
| 282 | |
| 283 | rt_handle |
| 284 | .spawn(f) |
| 285 | .await |
| 286 | .unwrap() |
| 287 | .map_err(|err| match err.downcast::<twilight_http::Error>() { |
| 288 | Ok(discord_err) => handle_discord_error(state, discord_err), |
| 289 | Err(err) => err, |
| 290 | }) |
| 291 | } |
| 292 | |
| 293 | pub async fn discord_request<T: Send + Sync + 'static>( |
| 294 | state: &Rc<RefCell<OpState>>, |
no test coverage detected