twilight_model/http/
channel_position.rs

1//! Models used when setting the channel positions over HTTP.
2
3use serde::{Deserialize, Serialize};
4
5use crate::id::{marker::ChannelMarker, Id};
6
7/// Used to update the position of channels over HTTP.
8///
9/// ## Note:
10///
11/// The fields with `Option<Option<T>>` will be `null` if they have
12/// the form `Some(None)`, `None` will be skipped.
13#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
14pub struct Position {
15    /// Channel id
16    pub id: Id<ChannelMarker>,
17    /// syncs the permission overwrites with the new parent, if moving
18    /// to a new category
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub lock_permissions: Option<Option<bool>>,
21    /// The new parent ID for the channel that is moved
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub parent_id: Option<Option<Id<ChannelMarker>>>,
24    /// Sorting position of the channel
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub position: Option<Option<u64>>,
27}
28
29impl From<(Id<ChannelMarker>, u64)> for Position {
30    fn from((id, position): (Id<ChannelMarker>, u64)) -> Self {
31        Self {
32            id,
33            lock_permissions: None,
34            parent_id: None,
35            position: Some(Some(position)),
36        }
37    }
38}