mirror of
https://github.com/Blah-IM/blahrs.git
synced 2025-08-18 10:12:38 +00:00
Ser/de bitflags as raw integers
This commit is contained in:
parent
501b3e8db4
commit
d672d067cd
3 changed files with 17 additions and 4 deletions
11
src/types.rs
11
src/types.rs
|
@ -4,6 +4,7 @@ use std::time::SystemTime;
|
|||
|
||||
use anyhow::{ensure, Context};
|
||||
use bitflags::bitflags;
|
||||
use bitflags_serde_shim::impl_serde_for_bitflags;
|
||||
use ed25519_dalek::{
|
||||
Signature, Signer, SigningKey, VerifyingKey, PUBLIC_KEY_LENGTH, SIGNATURE_LENGTH,
|
||||
};
|
||||
|
@ -115,14 +116,14 @@ pub enum RoomAdminPayload {
|
|||
}
|
||||
|
||||
bitflags! {
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct ServerPermission: u64 {
|
||||
const CREATE_ROOM = 1 << 0;
|
||||
|
||||
const ALL = !0;
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct RoomPermission: u64 {
|
||||
const PUSH_CHAT = 1 << 0;
|
||||
const ADD_MEMBER = 1 << 1;
|
||||
|
@ -130,7 +131,7 @@ bitflags! {
|
|||
const ALL = !0;
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
||||
pub struct RoomAttrs: u64 {
|
||||
const PUBLIC_READABLE = 1 << 0;
|
||||
|
||||
|
@ -138,6 +139,10 @@ bitflags! {
|
|||
}
|
||||
}
|
||||
|
||||
impl_serde_for_bitflags!(ServerPermission);
|
||||
impl_serde_for_bitflags!(RoomPermission);
|
||||
impl_serde_for_bitflags!(RoomAttrs);
|
||||
|
||||
mod sql_impl {
|
||||
use rusqlite::types::{FromSql, FromSqlError, FromSqlResult, ToSqlOutput, ValueRef};
|
||||
use rusqlite::{Result, ToSql};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue