twilight_model/guild/
role_position.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use crate::id::{marker::RoleMarker, Id};
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
/// Data used to update the positions of roles.
pub struct RolePosition {
    /// Role identifier.
    pub id: Id<RoleMarker>,
    /// Sorting position of the role.
    pub position: u64,
}

#[cfg(test)]
mod tests {
    use super::{Id, RolePosition};
    use serde_test::Token;

    #[test]
    fn role_position() {
        let role_position = RolePosition {
            id: Id::new(123),
            position: 12,
        };

        serde_test::assert_tokens(
            &role_position,
            &[
                Token::Struct {
                    name: "RolePosition",
                    len: 2,
                },
                Token::Str("id"),
                Token::NewtypeStruct { name: "Id" },
                Token::Str("123"),
                Token::Str("position"),
                Token::U64(12),
                Token::StructEnd,
            ],
        );
    }
}