mirror of
https://github.com/Blah-IM/blahrs.git
synced 2025-05-01 00:31:09 +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
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -209,6 +209,12 @@ name = "bitflags"
|
|||
version = "2.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags_serde_shim"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df031780c32b0f93cecaf883fa9e351e74679e24380c534aeef94556cfd80ac9"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
@ -220,6 +226,7 @@ dependencies = [
|
|||
"anyhow",
|
||||
"axum",
|
||||
"bitflags",
|
||||
"bitflags_serde_shim",
|
||||
"clap",
|
||||
"ed25519-dalek",
|
||||
"futures-util",
|
||||
|
|
|
@ -7,7 +7,8 @@ edition = "2021"
|
|||
[dependencies]
|
||||
anyhow = "1.0.86"
|
||||
axum = { version = "0.7.5", features = ["tokio"] }
|
||||
bitflags = { version = "2.6.0", features = ["serde"] }
|
||||
bitflags = "2.6.0"
|
||||
bitflags_serde_shim = "0.2.5"
|
||||
clap = { version = "4.5.16", features = ["derive"] }
|
||||
ed25519-dalek = { version = "2.1.1", features = ["digest", "serde"] }
|
||||
futures-util = "0.3.30"
|
||||
|
|
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
Reference in a new issue