Skip to content

Commit

Permalink
Avoid mixing permissions bits
Browse files Browse the repository at this point in the history
  • Loading branch information
novacrazy committed Nov 18, 2024
1 parent 67c58b0 commit 31e502f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/models/permission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ bitflags2! {
#[repr(C, align(16))]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Permissions: u128 {
/// Grants all permissions.
const ADMINISTRATOR = 1u128 << 0;
/// Allows a user to create invites for a party.
const CREATE_INVITE = 1u128 << 1;
const KICK_MEMBERS = 1u128 << 2;
const BAN_MEMBERS = 1u128 << 3;
Expand All @@ -52,8 +54,9 @@ bitflags2! {
const DEFAULT_ONLY = 1u128 << 20;

const VIEW_ROOM = 1u128 << 30;
const READ_MESSAGE_HISTORY = 1u128 << 31 | Self::VIEW_ROOM.bits();
const SEND_MESSAGES = 1u128 << 32 | Self::VIEW_ROOM.bits();
const READ_MESSAGE_HISTORY = 1u128 << 31;
const SEND_MESSAGES = 1u128 << 32;
/// Allows a user to manage messages in a room, including reactions.
const MANAGE_MESSAGES = 1u128 << 33;
const MUTE_MEMBERS = 1u128 << 34;
const DEAFEN_MEMBERS = 1u128 << 35;
Expand Down
5 changes: 5 additions & 0 deletions ts-bindgen/src/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ use core::fmt;
type Comment = Cow<'static, str>;
type Name = Cow<'static, str>;

/// Integer that'll be printed as a hexadecimal number in TypeScript.
///
/// This utility type ensures that values won't be zero-extending when converted
/// to TypeScript integers, even if negative signed integers are used. All values
/// are treated as unsigned integers for printing.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct BinaryInteger(pub u128);
Expand Down

0 comments on commit 31e502f

Please sign in to comment.