(
&'a self,
perms_buf: &'b mut Vec<twilight_model::channel::permission_overwrite::PermissionOverwrite>,
mut req: twilight_http::request::channel::UpdateChannel<'c>,
)
| 441 | |
| 442 | impl EditChannel { |
| 443 | pub fn apply<'a, 'b, 'c>( |
| 444 | &'a self, |
| 445 | perms_buf: &'b mut Vec<twilight_model::channel::permission_overwrite::PermissionOverwrite>, |
| 446 | mut req: twilight_http::request::channel::UpdateChannel<'c>, |
| 447 | ) -> Result<twilight_http::request::channel::UpdateChannel<'c>, ChannelValidationError> |
| 448 | where |
| 449 | 'a: 'c, |
| 450 | 'b: 'c, |
| 451 | { |
| 452 | if let Some(bitrate) = &self.bitrate { |
| 453 | req = req.bitrate(*bitrate); |
| 454 | } |
| 455 | |
| 456 | if let Some(name) = &self.name { |
| 457 | req = req.name(name); |
| 458 | } |
| 459 | |
| 460 | if let Some(nsfw) = &self.nsfw { |
| 461 | req = req.nsfw(*nsfw); |
| 462 | } |
| 463 | |
| 464 | if let Some(parent_id) = &self.parent_id { |
| 465 | // TODO: Should we error on invalid ID's? |
| 466 | let parent_id = parent_id |
| 467 | .as_ref() |
| 468 | .and_then(|s| Id::new_checked(s.parse().ok()?)); |
| 469 | |
| 470 | req = req.parent_id(parent_id); |
| 471 | } |
| 472 | |
| 473 | if let Some(permission_overwrites) = &self.permission_overwrites { |
| 474 | // TODO: should we error on bad overwrites instead of throwing them away? |
| 475 | perms_buf.extend( |
| 476 | permission_overwrites |
| 477 | .clone() |
| 478 | .into_iter() |
| 479 | .filter_map(|v| TryInto::<twilight_model::channel::permission_overwrite::PermissionOverwrite>::try_into(v).ok()), |
| 480 | ); |
| 481 | |
| 482 | req = req.permission_overwrites(perms_buf); |
| 483 | } |
| 484 | |
| 485 | if let Some(position) = &self.position { |
| 486 | req = req.position(position.0); |
| 487 | } |
| 488 | |
| 489 | if let Some(rate_limit_per_user) = &self.rate_limit_per_user { |
| 490 | req = req.rate_limit_per_user(*rate_limit_per_user); |
| 491 | } |
| 492 | |
| 493 | if let Some(topic) = &self.topic { |
| 494 | req = req.topic(topic); |
| 495 | } |
| 496 | |
| 497 | if let Some(user_limit) = &self.user_limit { |
| 498 | req = req.user_limit(*user_limit); |
| 499 | } |
| 500 |
no test coverage detected