mirror of
https://github.com/Blah-IM/blahrs.git
synced 2025-05-01 00:31:09 +00:00
refactor: move types crate into blahd-types
subpackage
This commit is contained in:
parent
0a0a4aefa9
commit
0ac841e6fa
13 changed files with 43 additions and 47 deletions
6
Cargo.lock
generated
6
Cargo.lock
generated
|
@ -260,7 +260,7 @@ dependencies = [
|
|||
]
|
||||
|
||||
[[package]]
|
||||
name = "blah"
|
||||
name = "blah-types"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
|
@ -283,7 +283,7 @@ name = "blahctl"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"blah",
|
||||
"blah-types",
|
||||
"clap",
|
||||
"ed25519-dalek",
|
||||
"hex",
|
||||
|
@ -300,7 +300,7 @@ dependencies = [
|
|||
"anyhow",
|
||||
"axum",
|
||||
"axum-extra",
|
||||
"blah",
|
||||
"blah-types",
|
||||
"clap",
|
||||
"ed25519-dalek",
|
||||
"futures-util",
|
||||
|
|
27
Cargo.toml
27
Cargo.toml
|
@ -1,7 +1,7 @@
|
|||
[workspace]
|
||||
resolver = "2"
|
||||
members = [
|
||||
".",
|
||||
"blah-types",
|
||||
"blahctl",
|
||||
"blahd",
|
||||
]
|
||||
|
@ -14,28 +14,3 @@ print_stderr = "warn"
|
|||
print_stdout = "warn"
|
||||
todo = "warn"
|
||||
unwrap_used = "warn"
|
||||
|
||||
[package]
|
||||
name = "blah"
|
||||
version = "0.0.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
bitflags = "2"
|
||||
bitflags_serde_shim = "0.2"
|
||||
ed25519-dalek = "2.1"
|
||||
hex = { version = "0.4", features = ["serde"] }
|
||||
html-escape = "0.2"
|
||||
rand = "0.8.5"
|
||||
rand_core = "0.6"
|
||||
rusqlite = { version = "0.32", optional = true }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_jcs = "0.1"
|
||||
serde_json = "1"
|
||||
serde_with = "3.9.0"
|
||||
|
||||
[dev-dependencies]
|
||||
expect-test = "1.5.0"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
24
blah-types/Cargo.toml
Normal file
24
blah-types/Cargo.toml
Normal file
|
@ -0,0 +1,24 @@
|
|||
[package]
|
||||
name = "blah-types"
|
||||
version = "0.0.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
bitflags = "2"
|
||||
bitflags_serde_shim = "0.2"
|
||||
ed25519-dalek = "2.1"
|
||||
hex = { version = "0.4", features = ["serde"] }
|
||||
html-escape = "0.2"
|
||||
rand = "0.8.5"
|
||||
rand_core = "0.6"
|
||||
rusqlite = { version = "0.32", optional = true }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_jcs = "0.1"
|
||||
serde_json = "1"
|
||||
serde_with = "3.9.0"
|
||||
|
||||
[dev-dependencies]
|
||||
expect-test = "1.5.0"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
|
@ -1,7 +1,6 @@
|
|||
use std::fmt;
|
||||
use std::time::SystemTime;
|
||||
|
||||
use bitflags::bitflags;
|
||||
use bitflags_serde_shim::impl_serde_for_bitflags;
|
||||
use ed25519_dalek::{
|
||||
Signature, SignatureError, Signer, SigningKey, VerifyingKey, PUBLIC_KEY_LENGTH,
|
||||
|
@ -11,6 +10,10 @@ use rand_core::RngCore;
|
|||
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
|
||||
use serde_with::{serde_as, DisplayFromStr};
|
||||
|
||||
// Re-export of public dependencies.
|
||||
pub use bitflags;
|
||||
pub use ed25519_dalek;
|
||||
|
||||
/// An opaque server-specific ID for room, chat item, and etc.
|
||||
/// It's currently serialized as a string for JavaScript's convenience.
|
||||
#[serde_as]
|
||||
|
@ -371,7 +374,7 @@ pub enum RoomAdminOp {
|
|||
// TODO: RU
|
||||
}
|
||||
|
||||
bitflags! {
|
||||
bitflags::bitflags! {
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct ServerPermission: u64 {
|
||||
const CREATE_ROOM = 1 << 0;
|
|
@ -13,7 +13,7 @@ reqwest = { version = "0.12", features = ["json"] }
|
|||
rusqlite = "0.32"
|
||||
tokio = { version = "1", features = ["rt", "macros"] }
|
||||
|
||||
blah = { path = "..", features = ["rusqlite"] }
|
||||
blah-types = { path = "../blah-types", features = ["rusqlite"] }
|
||||
|
||||
[lints.clippy]
|
||||
dbg_macro = "warn"
|
||||
|
|
|
@ -3,10 +3,9 @@ use std::path::{Path, PathBuf};
|
|||
use std::{fs, io};
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use blah::bitflags;
|
||||
use blah::types::{
|
||||
get_timestamp, ChatPayload, CreateRoomPayload, Id, MemberPermission, RichText, RoomAttrs,
|
||||
RoomMember, RoomMemberList, ServerPermission, UserKey, WithSig,
|
||||
use blah_types::{
|
||||
bitflags, get_timestamp, ChatPayload, CreateRoomPayload, Id, MemberPermission, RichText,
|
||||
RoomAttrs, RoomMember, RoomMemberList, ServerPermission, UserKey, WithSig,
|
||||
};
|
||||
use ed25519_dalek::pkcs8::spki::der::pem::LineEnding;
|
||||
use ed25519_dalek::pkcs8::{DecodePrivateKey, DecodePublicKey, EncodePrivateKey, EncodePublicKey};
|
||||
|
|
|
@ -27,7 +27,7 @@ tracing = "0.1"
|
|||
tracing-subscriber = "0.3"
|
||||
url = { version = "2.5.2", features = ["serde"] }
|
||||
|
||||
blah = { path = "..", features = ["rusqlite"] }
|
||||
blah-types = { path = "../blah-types", features = ["rusqlite"] }
|
||||
|
||||
[dev-dependencies]
|
||||
rand = "0.8.5"
|
||||
|
|
|
@ -8,7 +8,7 @@ use std::task::{Context, Poll};
|
|||
|
||||
use anyhow::{bail, Context as _, Result};
|
||||
use axum::extract::ws::{Message, WebSocket};
|
||||
use blah::types::{AuthPayload, ChatItem, WithSig};
|
||||
use blah_types::{AuthPayload, ChatItem, WithSig};
|
||||
use futures_util::future::Either;
|
||||
use futures_util::stream::SplitSink;
|
||||
use futures_util::{stream_select, SinkExt as _, Stream, StreamExt};
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/// FIXME: Currently we assume no more than one request in a single millisecond.
|
||||
use std::time::SystemTime;
|
||||
|
||||
use blah::types::Id;
|
||||
use blah_types::Id;
|
||||
|
||||
pub trait IdExt {
|
||||
fn gen() -> Self;
|
||||
|
|
|
@ -10,7 +10,7 @@ use axum::response::{IntoResponse, Response};
|
|||
use axum::routing::{get, post};
|
||||
use axum::{Json, Router};
|
||||
use axum_extra::extract::WithRejection as R;
|
||||
use blah::types::{
|
||||
use blah_types::{
|
||||
ChatItem, ChatPayload, CreateRoomPayload, Id, MemberPermission, RoomAdminOp, RoomAdminPayload,
|
||||
RoomAttrs, ServerPermission, Signee, UserKey, WithItemId, WithSig,
|
||||
};
|
||||
|
|
|
@ -6,7 +6,7 @@ use axum::extract::{FromRef, FromRequest, FromRequestParts, Request};
|
|||
use axum::http::{header, request, StatusCode};
|
||||
use axum::response::{IntoResponse, Response};
|
||||
use axum::{async_trait, Json};
|
||||
use blah::types::{AuthPayload, UserKey, WithSig};
|
||||
use blah_types::{AuthPayload, UserKey, WithSig};
|
||||
use serde::de::DeserializeOwned;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::future::IntoFuture;
|
|||
use std::sync::{Arc, LazyLock};
|
||||
|
||||
use anyhow::Result;
|
||||
use blah::types::{
|
||||
use blah_types::{
|
||||
get_timestamp, AuthPayload, CreateRoomPayload, Id, MemberPermission, RoomAdminOp,
|
||||
RoomAdminPayload, RoomAttrs, RoomMember, RoomMemberList, ServerPermission, UserKey, WithSig,
|
||||
};
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
// Re-export of public dependencies.
|
||||
pub use bitflags;
|
||||
pub use ed25519_dalek;
|
||||
|
||||
pub mod types;
|
Loading…
Add table
Reference in a new issue