From 7c6f4f3df770068dc9ddcdee79044b66a17447f6 Mon Sep 17 00:00:00 2001 From: namse Date: Tue, 25 Jun 2024 16:25:14 +0000 Subject: [PATCH] SEX --- .../new-server/database/database/Cargo.toml | 2 +- .../database/src/kv_store/in_memory.rs | 26 +- .../database/database/src/kv_store/mod.rs | 5 +- .../database/database/src/kv_store/sqlite.rs | 159 +- .../new-server/database/database/src/lib.rs | 54 +- .../new-server/database/schema/0/Cargo.lock | 357 +++ .../new-server/database/schema/0/src/lib.rs | 16 +- .../new-server/database/schema/1/.gitignore | 15 - .../new-server/database/schema/1/Cargo.lock | 7 - .../new-server/database/schema/1/Cargo.toml | 9 - .../new-server/database/schema/1/src/lib.rs | 6 - .../database/schema/document/Cargo.toml | 1 + .../document}/src/heap_archived.rs | 0 .../database/schema/document/src/lib.rs | 16 + .../database/schema/document/src/transact.rs | 213 ++ .../document}/src/value_buffer.rs | 0 .../database/schema/macro/Cargo.lock | 17 +- .../database/schema/macro/src/lib.rs | 246 +- .../database/schema/migration/Cargo.lock | 266 ++- .../database/schema/migration/Cargo.toml | 1 - .../database/schema/migration/build.rs | 28 +- .../schema/migration/src/latest_version.rs | 4 +- .../database/schema/migration/src/lib.rs | 21 +- luda-editor/new-server/rpc/Cargo.lock | 2013 +++++++++++++++-- luda-editor/new-server/rpc/Cargo.toml | 2 + luda-editor/new-server/rpc/build.rs | 17 +- luda-editor/new-server/rpc/macro/Cargo.toml | 3 +- luda-editor/new-server/rpc/macro/src/lib.rs | 30 +- .../src/lib.rs => macro/src/parser.rs} | 44 +- luda-editor/new-server/rpc/parser/.gitignore | 16 - luda-editor/new-server/rpc/parser/Cargo.lock | 47 - luda-editor/new-server/rpc/parser/Cargo.toml | 7 - .../new-server/rpc/parser/src/server.rs | 63 - luda-editor/new-server/rpc/src/data/cg.rs | 65 - .../new-server/rpc/src/data/cut/mod.rs | 5 - .../rpc/src/data/cut/previous/mod.rs | 7 - .../rpc/src/data/cut/previous/v0.rs | 33 - .../rpc/src/data/cut/previous/v1.rs | 124 - .../rpc/src/data/cut/previous/v2.rs | 50 - .../rpc/src/data/cut/previous/v3.rs | 52 - .../rpc/src/data/cut/previous/v4.rs | 47 - luda-editor/new-server/rpc/src/data/cut/v5.rs | 48 - .../rpc/src/data/cut_update_action.rs | 264 --- luda-editor/new-server/rpc/src/data/mod.rs | 234 -- .../rpc/src/data/screen_graphic/mod.rs | 4 - .../src/data/screen_graphic/previous/mod.rs | 3 - .../src/data/screen_graphic/previous/v0.rs | 76 - .../rpc/src/data/screen_graphic/v1.rs | 115 - .../rpc/src/data/sequence_update_action.rs | 52 - luda-editor/new-server/server/Cargo.lock | 27 +- luda-editor/new-server/server/Cargo.toml | 3 +- .../server/src/api/auth/google_auth.rs | 10 - .../server/src/api/auth/google_auth/mod.rs | 57 + .../api/{ => auth}/google_auth/verify_jwt.rs | 0 luda-editor/new-server/server/src/main.rs | 2 +- luda-editor/new-server/server/src/session.rs | 5 +- 56 files changed, 3326 insertions(+), 1668 deletions(-) delete mode 100644 luda-editor/new-server/database/schema/1/.gitignore delete mode 100644 luda-editor/new-server/database/schema/1/Cargo.lock delete mode 100644 luda-editor/new-server/database/schema/1/Cargo.toml delete mode 100644 luda-editor/new-server/database/schema/1/src/lib.rs rename luda-editor/new-server/database/{database => schema/document}/src/heap_archived.rs (100%) create mode 100644 luda-editor/new-server/database/schema/document/src/transact.rs rename luda-editor/new-server/database/{database => schema/document}/src/value_buffer.rs (100%) rename luda-editor/new-server/rpc/{parser/src/lib.rs => macro/src/parser.rs} (77%) delete mode 100644 luda-editor/new-server/rpc/parser/.gitignore delete mode 100644 luda-editor/new-server/rpc/parser/Cargo.lock delete mode 100644 luda-editor/new-server/rpc/parser/Cargo.toml delete mode 100644 luda-editor/new-server/rpc/parser/src/server.rs delete mode 100644 luda-editor/new-server/rpc/src/data/cg.rs delete mode 100644 luda-editor/new-server/rpc/src/data/cut/mod.rs delete mode 100644 luda-editor/new-server/rpc/src/data/cut/previous/mod.rs delete mode 100644 luda-editor/new-server/rpc/src/data/cut/previous/v0.rs delete mode 100644 luda-editor/new-server/rpc/src/data/cut/previous/v1.rs delete mode 100644 luda-editor/new-server/rpc/src/data/cut/previous/v2.rs delete mode 100644 luda-editor/new-server/rpc/src/data/cut/previous/v3.rs delete mode 100644 luda-editor/new-server/rpc/src/data/cut/previous/v4.rs delete mode 100644 luda-editor/new-server/rpc/src/data/cut/v5.rs delete mode 100644 luda-editor/new-server/rpc/src/data/cut_update_action.rs delete mode 100644 luda-editor/new-server/rpc/src/data/mod.rs delete mode 100644 luda-editor/new-server/rpc/src/data/screen_graphic/mod.rs delete mode 100644 luda-editor/new-server/rpc/src/data/screen_graphic/previous/mod.rs delete mode 100644 luda-editor/new-server/rpc/src/data/screen_graphic/previous/v0.rs delete mode 100644 luda-editor/new-server/rpc/src/data/screen_graphic/v1.rs delete mode 100644 luda-editor/new-server/rpc/src/data/sequence_update_action.rs delete mode 100644 luda-editor/new-server/server/src/api/auth/google_auth.rs create mode 100644 luda-editor/new-server/server/src/api/auth/google_auth/mod.rs rename luda-editor/new-server/server/src/api/{ => auth}/google_auth/verify_jwt.rs (100%) diff --git a/luda-editor/new-server/database/database/Cargo.toml b/luda-editor/new-server/database/database/Cargo.toml index 208fc288b..480d1189e 100644 --- a/luda-editor/new-server/database/database/Cargo.toml +++ b/luda-editor/new-server/database/database/Cargo.toml @@ -7,8 +7,8 @@ edition = "2021" anyhow = "1.0.86" aws-sdk-s3 = "1.34.0" quick_cache = "0.5.1" -rkyv = { version = "0.7.44", features = ["validation"] } rusqlite = { path = "../rusqlite-0.31.0", features = ["backup", "bundled"] } tokio = { version = "1.38.0", features = ["rt", "time"] } migration = { path = "../schema/migration" } document = { path = "../schema/document" } +rkyv = { version = "0.7.44", features = ["validation"] } diff --git a/luda-editor/new-server/database/database/src/kv_store/in_memory.rs b/luda-editor/new-server/database/database/src/kv_store/in_memory.rs index 8db4afae7..bf4ecd3fb 100644 --- a/luda-editor/new-server/database/database/src/kv_store/in_memory.rs +++ b/luda-editor/new-server/database/database/src/kv_store/in_memory.rs @@ -1,5 +1,5 @@ use super::KvStore; -use anyhow::Result; +use crate::Result; use quick_cache::sync::Cache; use std::{ sync::{atomic::AtomicBool, Arc}, @@ -115,14 +115,32 @@ impl KvStore for InMemoryCachedKsStore { ttl: Option, ) -> Result<()> { self.store.create(key.as_ref(), value_fn, ttl).await?; - if !self.enabled() { - return Ok(()); - } self.cache.remove(key.as_ref()); Ok(()) } + async fn transact( + &self, + transact_items: impl IntoIterator, + ) -> Result<()> { + let transact_items = transact_items.into_iter().collect::>(); + let keys = transact_items + .iter() + .map(|item| match item { + crate::TransactItem::Put { key, .. } => key.clone(), + crate::TransactItem::Create { key, .. } => key.clone(), + }) + .collect::>(); + + self.store.transact(transact_items).await?; + for key in keys { + self.cache.remove(&key); + } + + Ok(()) + } + // async fn update( // &self, // key: impl AsRef, diff --git a/luda-editor/new-server/database/database/src/kv_store/mod.rs b/luda-editor/new-server/database/database/src/kv_store/mod.rs index a39787141..9577881e8 100644 --- a/luda-editor/new-server/database/database/src/kv_store/mod.rs +++ b/luda-editor/new-server/database/database/src/kv_store/mod.rs @@ -2,7 +2,6 @@ mod in_memory; mod sqlite; use crate::*; -use anyhow::Result; pub(crate) use in_memory::*; pub(crate) use sqlite::*; use std::time::{Duration, SystemTime}; @@ -38,4 +37,8 @@ pub trait KvStore { value_fn: impl FnOnce() -> Result, ttl: Option, ) -> Result<()>; + async fn transact( + &self, + transact_items: impl IntoIterator, + ) -> Result<()>; } diff --git a/luda-editor/new-server/database/database/src/kv_store/sqlite.rs b/luda-editor/new-server/database/database/src/kv_store/sqlite.rs index 7586ac9aa..c1913f41d 100644 --- a/luda-editor/new-server/database/database/src/kv_store/sqlite.rs +++ b/luda-editor/new-server/database/database/src/kv_store/sqlite.rs @@ -1,7 +1,7 @@ use super::KvStore; -use anyhow::Result; +use crate::Result; use aws_sdk_s3::primitives::ByteStream; -use rusqlite::{Connection, OpenFlags, OptionalExtension}; +use rusqlite::{Connection, OpenFlags, OptionalExtension, Transaction}; use std::{ sync::{atomic::AtomicPtr, Arc, Mutex, MutexGuard}, time::{Duration, SystemTime}, @@ -16,7 +16,7 @@ const DB_PATH: &str = "db.sqlite"; const BACKUP_PATH: &str = "db.sqlite.backup"; impl SqliteKvStore { - pub async fn new(s3_client: aws_sdk_s3::Client, bucket_name: String) -> Result { + pub async fn new(s3_client: aws_sdk_s3::Client, bucket_name: String) -> anyhow::Result { try_fetch_db_file_from_s3(&s3_client, &bucket_name).await?; let conn = Connection::open(DB_PATH).unwrap(); @@ -148,27 +148,18 @@ impl KvStore for SqliteKvStore { value: &impl AsRef<[u8]>, ttl: Option, ) -> Result<()> { - let write_conn = self.write_conn(); - let mut stmt = write_conn.prepare( - " - INSERT OR REPLACE INTO kv_store - (key, value, version, expired_at) - VALUES (?, ?, 0, ?)", - )?; - - assert_eq!( - stmt.execute((key.as_ref(), value.as_ref(), ttl_to_expired_at(ttl)))?, - 1 - ); - + let mut write_conn = self.write_conn(); + let trx = write_conn.transaction()?; + put(&trx, key, value, ttl)?; + trx.commit()?; Ok(()) } async fn delete(&self, key: impl AsRef) -> Result<()> { - let write_conn = self.write_conn(); - let mut stmt = write_conn.prepare("DELETE FROM kv_store WHERE key = ?")?; - stmt.execute([key.as_ref()])?; - + let mut write_conn = self.write_conn(); + let trx = write_conn.transaction()?; + delete(&trx, key)?; + trx.commit()?; Ok(()) } @@ -178,36 +169,31 @@ impl KvStore for SqliteKvStore { value_fn: impl FnOnce() -> Result, ttl: Option, ) -> Result<()> { - let mut write_conn = self.write_conn(); - let tx = write_conn.transaction()?; - - let mut stmt = tx.prepare( - " - SELECT expired_at - FROM kv_store - WHERE key = ?", - )?; - let expired_at: Option = stmt - .query_row([key.as_ref()], |row| row.get(0)) - .optional()?; - if let Some(expired_at) = expired_at { - if expired_at == 0 || now_epoch_time_secs() < expired_at { - return Ok(()); - } - } + let mut write_conn: MutexGuard = self.write_conn(); + let trx = write_conn.transaction()?; + create(&trx, key, value_fn, ttl)?; + trx.commit()?; + Ok(()) + } - let value = value_fn()?; - let mut stmt = tx.prepare( - " - INSERT OR REPLACE INTO kv_store - (key, value, version, expired_at) - VALUES (?, ?, 0, ?)", - )?; - assert_eq!( - stmt.execute((key.as_ref(), value.as_ref(), ttl_to_expired_at(ttl)))?, - 1 - ); + async fn transact( + &self, + transact_items: impl IntoIterator, + ) -> Result<()> { + let mut write_conn: MutexGuard = self.write_conn(); + let trx = write_conn.transaction()?; + for item in transact_items.into_iter() { + match item { + crate::TransactItem::Put { key, value, ttl } => { + put(&trx, key, &value, ttl)?; + } + crate::TransactItem::Create { key, value, ttl } => { + create(&trx, key, || Ok(value), ttl)?; + } + } + } + trx.commit()?; Ok(()) } @@ -276,7 +262,7 @@ impl KvStore for SqliteKvStore { async fn try_fetch_db_file_from_s3( s3_client: &aws_sdk_s3::Client, bucket_name: &str, -) -> Result<()> { +) -> anyhow::Result<()> { if std::fs::metadata(DB_PATH).is_ok() { return Ok(()); } @@ -298,7 +284,7 @@ async fn backup( sqlite3: &AtomicPtr, s3_client: &aws_sdk_s3::Client, bucket_name: &str, -) -> Result<()> { +) -> anyhow::Result<()> { println!("Start Backup db.sqlite"); let now = std::time::SystemTime::now(); @@ -319,7 +305,10 @@ async fn backup( Ok(()) } -async fn save_db_backup_to_s3(s3_client: &aws_sdk_s3::Client, bucket_name: &str) -> Result<()> { +async fn save_db_backup_to_s3( + s3_client: &aws_sdk_s3::Client, + bucket_name: &str, +) -> anyhow::Result<()> { // TODO: multipart s3_client .put_object() @@ -332,7 +321,7 @@ async fn save_db_backup_to_s3(s3_client: &aws_sdk_s3::Client, bucket_name: &str) Ok(()) } -async fn migrate() -> Result<()> { +async fn migrate() -> anyhow::Result<()> { let pramga_conn = Connection::open(DB_PATH)?; let current_version = { let result = pramga_conn.query_row("PRAGMA kv_store.user_version", [], |row| { @@ -352,7 +341,7 @@ async fn migrate() -> Result<()> { fn map( &self, mut f: impl FnMut(From) -> To, - ) -> Result<()> { + ) -> anyhow::Result<()> { let read_conn = Connection::open_with_flags(DB_PATH, OpenFlags::SQLITE_OPEN_READ_ONLY).unwrap(); let mut write_conn = Connection::open(DB_PATH)?; @@ -406,3 +395,67 @@ fn now_epoch_time_secs() -> u64 { .unwrap() .as_secs() } + +fn put( + trx: &Transaction<'_>, + key: impl AsRef, + value: &impl AsRef<[u8]>, + ttl: Option, +) -> Result<()> { + let mut stmt = trx.prepare( + " + INSERT OR REPLACE INTO kv_store + (key, value, version, expired_at) + VALUES (?, ?, 0, ?)", + )?; + + assert_eq!( + stmt.execute((key.as_ref(), value.as_ref(), ttl_to_expired_at(ttl)))?, + 1 + ); + + Ok(()) +} + +fn delete(trx: &Transaction<'_>, key: impl AsRef) -> Result<()> { + let mut stmt = trx.prepare("DELETE FROM kv_store WHERE key = ?")?; + stmt.execute([key.as_ref()])?; + + Ok(()) +} + +fn create>( + trx: &Transaction<'_>, + key: impl AsRef, + value_fn: impl FnOnce() -> Result, + ttl: Option, +) -> Result<()> { + let mut stmt = trx.prepare( + " + SELECT expired_at + FROM kv_store + WHERE key = ?", + )?; + let expired_at: Option = stmt + .query_row([key.as_ref()], |row| row.get(0)) + .optional()?; + if let Some(expired_at) = expired_at { + if expired_at == 0 || now_epoch_time_secs() < expired_at { + return Ok(()); + } + } + + let value = value_fn()?; + let mut stmt = trx.prepare( + " + INSERT OR REPLACE INTO kv_store + (key, value, version, expired_at) + VALUES (?, ?, 0, ?)", + )?; + assert_eq!( + stmt.execute((key.as_ref(), value.as_ref(), ttl_to_expired_at(ttl)))?, + 1 + ); + + Ok(()) +} diff --git a/luda-editor/new-server/database/database/src/lib.rs b/luda-editor/new-server/database/database/src/lib.rs index dae5386c8..d3d28c563 100644 --- a/luda-editor/new-server/database/database/src/lib.rs +++ b/luda-editor/new-server/database/database/src/lib.rs @@ -1,17 +1,14 @@ -mod heap_archived; mod kv_store; -mod value_buffer; -use anyhow::Result; -pub use heap_archived::*; +use document::*; pub use kv_store::KvStore; -pub use value_buffer::*; +pub use migration::schema; pub async fn init( s3_client: aws_sdk_s3::Client, bucket_name: String, turn_on_in_memory_cache: bool, -) -> Result { +) -> anyhow::Result { let sqlite = kv_store::SqliteKvStore::new(s3_client, bucket_name).await?; let store = kv_store::InMemoryCachedKsStore::new(sqlite, turn_on_in_memory_cache); @@ -26,7 +23,45 @@ impl Database { pub fn set_memory_cache(&self, turn_on: bool) { self.store.set_cache_enabled(turn_on) } + pub async fn get( + &self, + document_get: impl DocumentGet, + ) -> Result>> { + let key = document_get.key(); + let value_buffer = self.store.get(key).await?; + Ok(value_buffer.map(|value_buffer| T::heap_archived(value_buffer))) + } + + pub async fn transact(&self, transact: impl Transact) -> Result<()> { + let transact_items = transact.try_into_transact_items()?; + KvStore::transact(self, transact_items).await + } +} + +#[derive(Debug)] +pub enum Error { + SqliteError(rusqlite::Error), + SerializationError(SerErr), +} +impl std::fmt::Display for Error { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{:?}", self) + } +} +impl std::error::Error for Error {} + +impl From for Error { + fn from(e: rusqlite::Error) -> Self { + Error::SqliteError(e) + } } +impl From for Error { + fn from(e: SerErr) -> Self { + Error::SerializationError(e) + } +} + +pub type Result = std::result::Result; impl KvStore for Database { async fn get(&self, key: impl AsRef) -> Result> { @@ -61,4 +96,11 @@ impl KvStore for Database { ) -> Result<()> { self.store.create(key, value_fn, ttl).await } + + async fn transact( + &self, + transact_items: impl IntoIterator, + ) -> Result<()> { + self.store.transact(transact_items).await + } } diff --git a/luda-editor/new-server/database/schema/0/Cargo.lock b/luda-editor/new-server/database/schema/0/Cargo.lock index 2ea14e9d2..9ef3f2d6b 100644 --- a/luda-editor/new-server/database/schema/0/Cargo.lock +++ b/luda-editor/new-server/database/schema/0/Cargo.lock @@ -2,6 +2,363 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "ahash" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + +[[package]] +name = "anyhow" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +dependencies = [ + "backtrace", +] + +[[package]] +name = "backtrace" +version = "0.3.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "bytecheck" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23cdc57ce23ac53c931e88a43d06d070a6fd142f2617be5855eb75efc9beb1c2" +dependencies = [ + "bytecheck_derive", + "ptr_meta", + "simdutf8", +] + +[[package]] +name = "bytecheck_derive" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3db406d29fbcd95542e92559bed4d8ad92636d1ca8b3b72ede10b4bcc010e659" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "bytes" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" + +[[package]] +name = "cc" +version = "1.0.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c891175c3fb232128f48de6590095e59198bbeb8620c310be349bfc3afd12c7b" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "document" +version = "0.1.0" +dependencies = [ + "anyhow", + "rkyv", + "schema-macro", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "gimli" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash", +] + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "miniz_oxide" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" +dependencies = [ + "adler", +] + +[[package]] +name = "object" +version = "0.36.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "576dfe1fc8f9df304abb159d767a29d0476f7750fbf8aa7ad07816004a207434" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "proc-macro2" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "ptr_meta" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rend" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71fe3824f5629716b1589be05dacd749f6aa084c87e00e016714a8cdfccc997c" +dependencies = [ + "bytecheck", +] + +[[package]] +name = "rkyv" +version = "0.7.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cba464629b3394fc4dbc6f940ff8f5b4ff5c7aef40f29166fd4ad12acbc99c0" +dependencies = [ + "bitvec", + "bytecheck", + "bytes", + "hashbrown", + "ptr_meta", + "rend", + "rkyv_derive", + "seahash", + "tinyvec", + "uuid", +] + +[[package]] +name = "rkyv_derive" +version = "0.7.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7dddfff8de25e6f62b9d64e6e432bf1c6736c57d20323e15ee10435fbda7c65" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + [[package]] name = "schema-0" version = "0.0.1" +dependencies = [ + "document", + "rkyv", + "schema-macro", +] + +[[package]] +name = "schema-macro" +version = "0.1.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "seahash" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" + +[[package]] +name = "simdutf8" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "tinyvec" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c55115c6fbe2d2bef26eb09ad74bde02d8255476fc0c7b515ef09fbb35742d82" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "uuid" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5de17fd2f7da591098415cff336e12965a28061ddace43b59cb3c430179c9439" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] diff --git a/luda-editor/new-server/database/schema/0/src/lib.rs b/luda-editor/new-server/database/schema/0/src/lib.rs index e274ce01f..95ee5cc53 100644 --- a/luda-editor/new-server/database/schema/0/src/lib.rs +++ b/luda-editor/new-server/database/schema/0/src/lib.rs @@ -1,5 +1,15 @@ -#[schema_macro::schema] -pub struct MyDocument { +use schema_macro::schema; + +#[schema] +pub struct UserDoc { + #[pk] + pub id: String, pub name: String, - pub content: String, +} + +#[schema] +pub struct GoogleIdentityDoc { + #[pk] + pub sub: String, + pub user_id: String, } diff --git a/luda-editor/new-server/database/schema/1/.gitignore b/luda-editor/new-server/database/schema/1/.gitignore deleted file mode 100644 index c38d504ca..000000000 --- a/luda-editor/new-server/database/schema/1/.gitignore +++ /dev/null @@ -1,15 +0,0 @@ -# Edit at https://www.toptal.com/developers/gitignore?templates=rust - -### Rust ### -# Generated by Cargo -# will have compiled files and executables -debug/ -target/ - -# These are backup files generated by rustfmt -**/*.rs.bk - -# MSVC Windows builds of rustc generate these, which store debugging information -*.pdb - -# End of https://www.toptal.com/developers/gitignore/api/rust \ No newline at end of file diff --git a/luda-editor/new-server/database/schema/1/Cargo.lock b/luda-editor/new-server/database/schema/1/Cargo.lock deleted file mode 100644 index 258ea57b9..000000000 --- a/luda-editor/new-server/database/schema/1/Cargo.lock +++ /dev/null @@ -1,7 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "schema-1" -version = "0.0.1" diff --git a/luda-editor/new-server/database/schema/1/Cargo.toml b/luda-editor/new-server/database/schema/1/Cargo.toml deleted file mode 100644 index 66d518d0b..000000000 --- a/luda-editor/new-server/database/schema/1/Cargo.toml +++ /dev/null @@ -1,9 +0,0 @@ -[package] -name = "schema-1" -version = "0.0.1" -edition = "2021" - -[dependencies] -document = { path = "../document" } -schema-macro = { path = "../macro" } -rkyv = { version = "0.7.44" } diff --git a/luda-editor/new-server/database/schema/1/src/lib.rs b/luda-editor/new-server/database/schema/1/src/lib.rs deleted file mode 100644 index 1f8c0efe9..000000000 --- a/luda-editor/new-server/database/schema/1/src/lib.rs +++ /dev/null @@ -1,6 +0,0 @@ -#[schema_macro::schema] -pub struct MyDocument { - pub name: String, - pub content: String, - pub tags: Vec, -} diff --git a/luda-editor/new-server/database/schema/document/Cargo.toml b/luda-editor/new-server/database/schema/document/Cargo.toml index 64c8158bc..de8c3eae2 100644 --- a/luda-editor/new-server/database/schema/document/Cargo.toml +++ b/luda-editor/new-server/database/schema/document/Cargo.toml @@ -6,3 +6,4 @@ edition = "2021" [dependencies] schema-macro = { path = "../macro" } anyhow = { version = "1.0.86", features = ["backtrace"] } +rkyv = { version = "0.7.44", features = ["validation"] } diff --git a/luda-editor/new-server/database/database/src/heap_archived.rs b/luda-editor/new-server/database/schema/document/src/heap_archived.rs similarity index 100% rename from luda-editor/new-server/database/database/src/heap_archived.rs rename to luda-editor/new-server/database/schema/document/src/heap_archived.rs diff --git a/luda-editor/new-server/database/schema/document/src/lib.rs b/luda-editor/new-server/database/schema/document/src/lib.rs index 8b45190e9..5b558e4b5 100644 --- a/luda-editor/new-server/database/schema/document/src/lib.rs +++ b/luda-editor/new-server/database/schema/document/src/lib.rs @@ -1,9 +1,25 @@ +mod heap_archived; +mod transact; +mod value_buffer; + pub use anyhow::Result; +pub use heap_archived::*; +pub use transact::*; +pub use value_buffer::ValueBuffer; pub trait Document { fn name() -> &'static str; + fn heap_archived(value_buffer: ValueBuffer) -> HeapArchived + where + Self: Sized; fn from_bytes(bytes: Vec) -> Result where Self: Sized; fn to_bytes(&self) -> Result>; } + +pub trait DocumentGet { + type Output; + + fn key(&self) -> String; +} diff --git a/luda-editor/new-server/database/schema/document/src/transact.rs b/luda-editor/new-server/database/schema/document/src/transact.rs new file mode 100644 index 000000000..17560519e --- /dev/null +++ b/luda-editor/new-server/database/schema/document/src/transact.rs @@ -0,0 +1,213 @@ +use crate::*; +use std::time::Duration; + +pub type SerErr = rkyv::ser::serializers::CompositeSerializerError< + std::convert::Infallible, + rkyv::ser::serializers::AllocScratchError, + rkyv::ser::serializers::SharedSerializeMapError, +>; + +pub enum TransactItem { + Put { + key: String, + value: Vec, + ttl: Option, + }, + Create { + key: String, + value: Vec, + ttl: Option, + }, +} + +pub trait Transact { + fn try_into_transact_items(self) -> Result, SerErr>; +} +impl> Transact for T { + fn try_into_transact_items(self) -> Result, SerErr> { + Ok([self.try_into()?]) + } +} +impl, T2: TryInto> Transact + for (T1, T2) +{ + fn try_into_transact_items(self) -> Result, SerErr> { + let (t1, t2) = self; + Ok([t1.try_into()?, t2.try_into()?]) + } +} +impl< + T1: TryInto, + T2: TryInto, + T3: TryInto, + > Transact for (T1, T2, T3) +{ + fn try_into_transact_items(self) -> Result, SerErr> { + let (t1, t2, t3) = self; + Ok([t1.try_into()?, t2.try_into()?, t3.try_into()?]) + } +} +impl< + T1: TryInto, + T2: TryInto, + T3: TryInto, + T4: TryInto, + > Transact for (T1, T2, T3, T4) +{ + fn try_into_transact_items(self) -> Result, SerErr> { + let (t1, t2, t3, t4) = self; + Ok([ + t1.try_into()?, + t2.try_into()?, + t3.try_into()?, + t4.try_into()?, + ]) + } +} +impl< + T1: TryInto, + T2: TryInto, + T3: TryInto, + T4: TryInto, + T5: TryInto, + > Transact for (T1, T2, T3, T4, T5) +{ + fn try_into_transact_items(self) -> Result, SerErr> { + let (t1, t2, t3, t4, t5) = self; + Ok([ + t1.try_into()?, + t2.try_into()?, + t3.try_into()?, + t4.try_into()?, + t5.try_into()?, + ]) + } +} +impl< + T1: TryInto, + T2: TryInto, + T3: TryInto, + T4: TryInto, + T5: TryInto, + T6: TryInto, + > Transact for (T1, T2, T3, T4, T5, T6) +{ + fn try_into_transact_items(self) -> Result, SerErr> { + let (t1, t2, t3, t4, t5, t6) = self; + Ok([ + t1.try_into()?, + t2.try_into()?, + t3.try_into()?, + t4.try_into()?, + t5.try_into()?, + t6.try_into()?, + ]) + } +} +impl< + T1: TryInto, + T2: TryInto, + T3: TryInto, + T4: TryInto, + T5: TryInto, + T6: TryInto, + T7: TryInto, + > Transact for (T1, T2, T3, T4, T5, T6, T7) +{ + fn try_into_transact_items(self) -> Result, SerErr> { + let (t1, t2, t3, t4, t5, t6, t7) = self; + Ok([ + t1.try_into()?, + t2.try_into()?, + t3.try_into()?, + t4.try_into()?, + t5.try_into()?, + t6.try_into()?, + t7.try_into()?, + ]) + } +} + +impl< + T1: TryInto, + T2: TryInto, + T3: TryInto, + T4: TryInto, + T5: TryInto, + T6: TryInto, + T7: TryInto, + T8: TryInto, + > Transact for (T1, T2, T3, T4, T5, T6, T7, T8) +{ + fn try_into_transact_items(self) -> Result, SerErr> { + let (t1, t2, t3, t4, t5, t6, t7, t8) = self; + Ok([ + t1.try_into()?, + t2.try_into()?, + t3.try_into()?, + t4.try_into()?, + t5.try_into()?, + t6.try_into()?, + t7.try_into()?, + t8.try_into()?, + ]) + } +} + +impl< + T1: TryInto, + T2: TryInto, + T3: TryInto, + T4: TryInto, + T5: TryInto, + T6: TryInto, + T7: TryInto, + T8: TryInto, + T9: TryInto, + > Transact for (T1, T2, T3, T4, T5, T6, T7, T8, T9) +{ + fn try_into_transact_items(self) -> Result, SerErr> { + let (t1, t2, t3, t4, t5, t6, t7, t8, t9) = self; + Ok([ + t1.try_into()?, + t2.try_into()?, + t3.try_into()?, + t4.try_into()?, + t5.try_into()?, + t6.try_into()?, + t7.try_into()?, + t8.try_into()?, + t9.try_into()?, + ]) + } +} + +impl< + T1: TryInto, + T2: TryInto, + T3: TryInto, + T4: TryInto, + T5: TryInto, + T6: TryInto, + T7: TryInto, + T8: TryInto, + T9: TryInto, + T10: TryInto, + > Transact for (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) +{ + fn try_into_transact_items(self) -> Result, SerErr> { + let (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) = self; + Ok([ + t1.try_into()?, + t2.try_into()?, + t3.try_into()?, + t4.try_into()?, + t5.try_into()?, + t6.try_into()?, + t7.try_into()?, + t8.try_into()?, + t9.try_into()?, + t10.try_into()?, + ]) + } +} diff --git a/luda-editor/new-server/database/database/src/value_buffer.rs b/luda-editor/new-server/database/schema/document/src/value_buffer.rs similarity index 100% rename from luda-editor/new-server/database/database/src/value_buffer.rs rename to luda-editor/new-server/database/schema/document/src/value_buffer.rs diff --git a/luda-editor/new-server/database/schema/macro/Cargo.lock b/luda-editor/new-server/database/schema/macro/Cargo.lock index abeffad54..c273b8ae2 100755 --- a/luda-editor/new-server/database/schema/macro/Cargo.lock +++ b/luda-editor/new-server/database/schema/macro/Cargo.lock @@ -2,15 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "migration-macro" -version = "0.1.0" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "proc-macro2" version = "1.0.51" @@ -29,6 +20,14 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "schema-macro" +version = "0.1.0" +dependencies = [ + "quote", + "syn", +] + [[package]] name = "syn" version = "1.0.109" diff --git a/luda-editor/new-server/database/schema/macro/src/lib.rs b/luda-editor/new-server/database/schema/macro/src/lib.rs index 59c050a24..b590eb3ae 100644 --- a/luda-editor/new-server/database/schema/macro/src/lib.rs +++ b/luda-editor/new-server/database/schema/macro/src/lib.rs @@ -1,5 +1,6 @@ use quote::quote; -use syn::parse_macro_input; +use spanned::Spanned; +use syn::*; #[proc_macro_attribute] pub fn schema( @@ -7,18 +8,28 @@ pub fn schema( input: proc_macro::TokenStream, ) -> proc_macro::TokenStream { let input: syn::DeriveInput = parse_macro_input!(input as syn::DeriveInput); + let parsed = Parsed::new(&input); + let struct_name = &input.ident; - let struct_name = input.ident.clone(); + let struct_get_define = struct_get_define(&parsed); + let struct_put_define = struct_put_define(&parsed); + let struct_create_define = struct_create_define(&parsed); + + let attrs_removed_input = &parsed.attrs_removed_input; let output = quote! { #[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)] - #input + #attrs_removed_input impl document::Document for #struct_name { fn name() -> &'static str { stringify!(#struct_name) } + fn heap_archived(value_buffer: document::ValueBuffer) -> document::HeapArchived { + document::HeapArchived::new(value_buffer) + } + fn from_bytes(bytes: Vec) -> document::Result { unsafe { Ok(rkyv::from_bytes_unchecked(&bytes)?) } } @@ -28,7 +39,236 @@ pub fn schema( } } + #struct_get_define + #struct_put_define + #struct_create_define }; output.into() } + +fn struct_get_define( + Parsed { + name, + pk_fields_without_pk_attr, + .. + }: &Parsed, +) -> impl quote::ToTokens { + let get_struct_name = Ident::new(&format!("{}Get", name), name.span()); + let pk_fields_names = pk_fields_without_pk_attr + .iter() + .map(|field| field.ident.as_ref().unwrap()); + let pk_fields_as_refs = pk_fields_without_pk_attr.iter().map(|field| { + let mut field = field.clone(); + field.ty = Type::Reference(TypeReference { + and_token: Default::default(), + lifetime: Some(Lifetime::new("'a", field.span())), + mutability: None, + elem: Box::new(field.ty), + }); + field + }); + + quote! { + pub struct #get_struct_name<'a> { + #(#pk_fields_as_refs),* + } + impl document::DocumentGet for #get_struct_name<'_> { + type Output = #name; + fn key(&self) -> String { + let mut key = String::new(); + #( + key += &format!("{}:{}", stringify!(#pk_fields_names),self.#pk_fields_names); + )* + key + } + } + } +} + +fn struct_put_define( + Parsed { + name, + pk_fields_without_pk_attr, + fields_without_pk_attr, + .. + }: &Parsed, +) -> impl quote::ToTokens { + let put_struct_name = Ident::new(&format!("{}Put", name), name.span()); + let put_struct_name_internal = Ident::new(&format!("Internal{}Put", name), name.span()); + let pk_fields_names = pk_fields_without_pk_attr + .iter() + .map(|field| field.ident.as_ref().unwrap()); + let fields_as_refs = fields_without_pk_attr + .iter() + .map(|field| { + let mut field = field.clone(); + field.ty = Type::Reference(TypeReference { + and_token: Default::default(), + lifetime: Some(Lifetime::new("'a", field.span())), + mutability: None, + elem: Box::new(field.ty), + }); + field + }) + .collect::>(); + let fields_names = fields_as_refs + .iter() + .map(|field| field.ident.as_ref().unwrap()); + + quote! { + pub struct #put_struct_name<'a> { + #(#fields_as_refs,)* + pub ttl: Option, + } + #[derive(rkyv::Archive, rkyv::Serialize)] + struct #put_struct_name_internal<'a> { + #( + #[with(rkyv::with::Inline)] + #fields_as_refs, + )* + } + impl TryInto for #put_struct_name<'_> { + type Error = document::SerErr; + fn try_into(self) -> Result { + let key = { + let mut key = String::new(); + #( + key += &format!("{}:{}", stringify!(#pk_fields_names),self.#pk_fields_names); + )* + key + }; + + use rkyv::ser::{serializers::AllocSerializer, Serializer}; + let mut serializer = AllocSerializer::<1024>::default(); + serializer.serialize_value(&#put_struct_name_internal{ + #( + #fields_names: self.#fields_names, + )* + })?; + let value = serializer.into_serializer().into_inner().to_vec(); + + Ok(document::TransactItem::Put { + key, + value, + ttl: self.ttl + }) + } + } + } +} + +fn struct_create_define( + Parsed { + name, + pk_fields_without_pk_attr, + fields_without_pk_attr, + .. + }: &Parsed, +) -> impl quote::ToTokens { + let create_struct_name = Ident::new(&format!("{}Create", name), name.span()); + let create_struct_name_internal = Ident::new(&format!("Internal{}Create", name), name.span()); + let pk_fields_names = pk_fields_without_pk_attr + .iter() + .map(|field| field.ident.as_ref().unwrap()); + let fields_as_refs = fields_without_pk_attr + .iter() + .map(|field| { + let mut field = field.clone(); + field.ty = Type::Reference(TypeReference { + and_token: Default::default(), + lifetime: Some(Lifetime::new("'a", field.span())), + mutability: None, + elem: Box::new(field.ty), + }); + field + }) + .collect::>(); + let fields_names = fields_as_refs + .iter() + .map(|field| field.ident.as_ref().unwrap()); + + quote! { + pub struct #create_struct_name<'a> { + #(#fields_as_refs,)* + pub ttl: Option, + } + #[derive(rkyv::Archive, rkyv::Serialize)] + struct #create_struct_name_internal<'a> { + #( + #[with(rkyv::with::Inline)] + #fields_as_refs, + )* + } + impl TryInto for #create_struct_name<'_> { + type Error = document::SerErr; + fn try_into(self) -> Result { + let key = { + let mut key = String::new(); + #( + key += &format!("{}:{}", stringify!(#pk_fields_names),self.#pk_fields_names); + )* + key + }; + + Ok(document::TransactItem::Create { + key, + value: { + use rkyv::ser::{serializers::AllocSerializer, Serializer}; + let mut serializer = AllocSerializer::<1024>::default(); + serializer.serialize_value(&#create_struct_name_internal{ + #( + #fields_names: self.#fields_names, + )* + })?; + serializer.into_serializer().into_inner().to_vec() + }, + ttl: self.ttl + }) + } + } + } +} + +struct Parsed<'a> { + name: &'a Ident, + data_struct: &'a DataStruct, + attrs_removed_input: DeriveInput, + pk_fields_without_pk_attr: Vec, + fields_without_pk_attr: Vec, +} + +impl<'a> Parsed<'a> { + fn new(input: &'a DeriveInput) -> Self { + let name = &input.ident; + let data_struct = match &input.data { + Data::Struct(data) => data, + _ => panic!("Document can only be derived on structs"), + }; + + let mut attrs_removed_input = input.clone(); + let mut pk_fields_without_pk_attr = Vec::new(); + let mut fields_without_pk_attr = Vec::new(); + { + let struct_input = match &mut attrs_removed_input.data { + Data::Struct(data) => data, + _ => unreachable!(), + }; + struct_input.fields.iter_mut().for_each(|field| { + if field.attrs.iter().any(|attr| attr.path.is_ident("pk")) { + field.attrs.retain(|attr| !attr.path.is_ident("pk")); + pk_fields_without_pk_attr.push(field.clone()); + } + fields_without_pk_attr.push(field.clone()); + }); + } + + Self { + name, + data_struct, + attrs_removed_input, + pk_fields_without_pk_attr, + fields_without_pk_attr, + } + } +} diff --git a/luda-editor/new-server/database/schema/migration/Cargo.lock b/luda-editor/new-server/database/schema/migration/Cargo.lock index 7c0d7e04a..c9c3e7713 100644 --- a/luda-editor/new-server/database/schema/migration/Cargo.lock +++ b/luda-editor/new-server/database/schema/migration/Cargo.lock @@ -17,6 +17,17 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "ahash" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + [[package]] name = "anyhow" version = "1.0.86" @@ -41,6 +52,46 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "bytecheck" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23cdc57ce23ac53c931e88a43d06d070a6fd142f2617be5855eb75efc9beb1c2" +dependencies = [ + "bytecheck_derive", + "ptr_meta", + "simdutf8", +] + +[[package]] +name = "bytecheck_derive" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3db406d29fbcd95542e92559bed4d8ad92636d1ca8b3b72ede10b4bcc010e659" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "bytes" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" + [[package]] name = "cc" version = "1.0.99" @@ -53,12 +104,47 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "document" +version = "0.1.0" +dependencies = [ + "anyhow", + "rkyv", + "schema-macro", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + [[package]] name = "gimli" version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash", +] + [[package]] name = "libc" version = "0.2.155" @@ -76,8 +162,8 @@ name = "migration" version = "0.1.0" dependencies = [ "anyhow", + "document", "schema-0", - "schema-1", ] [[package]] @@ -98,6 +184,94 @@ dependencies = [ "memchr", ] +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "proc-macro2" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "ptr_meta" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rend" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71fe3824f5629716b1589be05dacd749f6aa084c87e00e016714a8cdfccc997c" +dependencies = [ + "bytecheck", +] + +[[package]] +name = "rkyv" +version = "0.7.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cba464629b3394fc4dbc6f940ff8f5b4ff5c7aef40f29166fd4ad12acbc99c0" +dependencies = [ + "bitvec", + "bytecheck", + "bytes", + "hashbrown", + "ptr_meta", + "rend", + "rkyv_derive", + "seahash", + "tinyvec", + "uuid", +] + +[[package]] +name = "rkyv_derive" +version = "0.7.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7dddfff8de25e6f62b9d64e6e432bf1c6736c57d20323e15ee10435fbda7c65" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "rustc-demangle" version = "0.1.24" @@ -107,7 +281,93 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "schema-0" version = "0.0.1" +dependencies = [ + "document", + "rkyv", + "schema-macro", +] [[package]] -name = "schema-1" -version = "0.0.1" +name = "schema-macro" +version = "0.1.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "seahash" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" + +[[package]] +name = "simdutf8" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "tinyvec" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c55115c6fbe2d2bef26eb09ad74bde02d8255476fc0c7b515ef09fbb35742d82" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "uuid" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5de17fd2f7da591098415cff336e12965a28061ddace43b59cb3c430179c9439" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] diff --git a/luda-editor/new-server/database/schema/migration/Cargo.toml b/luda-editor/new-server/database/schema/migration/Cargo.toml index 140dd0238..518758e32 100644 --- a/luda-editor/new-server/database/schema/migration/Cargo.toml +++ b/luda-editor/new-server/database/schema/migration/Cargo.toml @@ -8,4 +8,3 @@ anyhow = { version = "1.0.86", features = ["backtrace"] } document = { path = "../document" } schema-0 = { path = "../0", package = "schema-0" } -schema-1 = { path = "../1", package = "schema-1" } diff --git a/luda-editor/new-server/database/schema/migration/build.rs b/luda-editor/new-server/database/schema/migration/build.rs index cadc2f546..fe7502613 100644 --- a/luda-editor/new-server/database/schema/migration/build.rs +++ b/luda-editor/new-server/database/schema/migration/build.rs @@ -1,13 +1,10 @@ use std::path::Path; -#[path = "src/latest_version.rs"] -mod latest_version; - fn main() { let root = std::env::var("CARGO_MANIFEST_DIR").unwrap(); let dir = std::fs::read_dir(Path::new(&root).parent().unwrap()).unwrap(); - let mut biggest: Option = None; + let mut latest_version: Option = None; for entry in dir { let entry = entry.unwrap(); let path = entry.path(); @@ -16,21 +13,24 @@ fn main() { let Ok(value) = str::parse::(name) else { continue; }; - if biggest.is_none() || value > biggest.unwrap() { - biggest = Some(value); + if latest_version.is_none() || value > latest_version.unwrap() { + latest_version = Some(value); } } } - let Some(biggest) = biggest else { + let Some(latest_version) = latest_version else { panic!("no version found"); }; - if latest_version::LATEST_VERSION != biggest { - panic!( - "expected latest version to be {}, but found {}", - biggest, - latest_version::LATEST_VERSION - ); - } + std::fs::write( + std::path::Path::new("./src/latest_version.rs"), + format!( + "//! Generated by build.rs +pub use schema_{latest_version} as schema; +pub const LATEST_VERSION: usize = {latest_version}; +", + ), + ) + .unwrap(); } diff --git a/luda-editor/new-server/database/schema/migration/src/latest_version.rs b/luda-editor/new-server/database/schema/migration/src/latest_version.rs index 395ba3ebd..e1dd90a47 100644 --- a/luda-editor/new-server/database/schema/migration/src/latest_version.rs +++ b/luda-editor/new-server/database/schema/migration/src/latest_version.rs @@ -1 +1,3 @@ -pub const LATEST_VERSION: usize = 1; +//! Generated by build.rs +pub use schema_0 as schema; +pub const LATEST_VERSION: usize = 0; diff --git a/luda-editor/new-server/database/schema/migration/src/lib.rs b/luda-editor/new-server/database/schema/migration/src/lib.rs index b133ca96f..0cdb3fc00 100644 --- a/luda-editor/new-server/database/schema/migration/src/lib.rs +++ b/luda-editor/new-server/database/schema/migration/src/lib.rs @@ -1,11 +1,18 @@ mod latest_version; -mod migrate_0_1; +// mod migrate_0_1; use anyhow::Result; pub use latest_version::*; -pub async fn migrate(from_version: usize, db_conn: impl DatabaseConnection) -> Result<()> { - assert!(from_version <= LATEST_VERSION); +pub async fn migrate( + from_version: usize, + #[allow(unused_variables)] db_conn: impl DatabaseConnection, +) -> Result<()> { + #[allow(clippy::absurd_extreme_comparisons)] + { + assert!(from_version <= LATEST_VERSION); + } + if from_version == LATEST_VERSION { return Ok(()); } @@ -13,13 +20,15 @@ pub async fn migrate(from_version: usize, db_conn: impl DatabaseConnection) -> R eprintln!("WARN: version gap is greater than 1. {from_version} -> {LATEST_VERSION}"); } + #[allow(clippy::match_single_binding)] match from_version { - 0 => { - migrate_0_1::migrate(db_conn)?; - } + // 0 => { + // migrate_0_1::migrate(db_conn)?; + // } _ => unreachable!(), } + #[allow(unreachable_code)] Ok(()) } diff --git a/luda-editor/new-server/rpc/Cargo.lock b/luda-editor/new-server/rpc/Cargo.lock index c726aae00..fdc3f9924 100755 --- a/luda-editor/new-server/rpc/Cargo.lock +++ b/luda-editor/new-server/rpc/Cargo.lock @@ -2,6 +2,21 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "ahash" version = "0.7.8" @@ -14,283 +29,1985 @@ dependencies = [ ] [[package]] -name = "bitvec" -version = "1.0.1" +name = "ahash" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ - "funty", - "radium", - "tap", - "wyz", + "cfg-if", + "getrandom", + "once_cell", + "version_check", + "zerocopy", ] [[package]] -name = "bytecheck" -version = "0.6.12" +name = "allocator-api2" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23cdc57ce23ac53c931e88a43d06d070a6fd142f2617be5855eb75efc9beb1c2" -dependencies = [ - "bytecheck_derive", - "ptr_meta", - "simdutf8", -] +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] -name = "bytecheck_derive" -version = "0.6.12" +name = "anyhow" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3db406d29fbcd95542e92559bed4d8ad92636d1ca8b3b72ede10b4bcc010e659" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", + "backtrace", ] [[package]] -name = "bytes" -version = "1.6.0" +name = "autocfg" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] -name = "cfg-if" -version = "1.0.0" +name = "aws-credential-types" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "e16838e6c9e12125face1c1eff1343c75e3ff540de98ff7ebd61874a89bcfeb9" +dependencies = [ + "aws-smithy-async", + "aws-smithy-runtime-api", + "aws-smithy-types", + "zeroize", +] [[package]] -name = "funty" -version = "2.0.0" +name = "aws-runtime" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" +checksum = "9a4a5e448145999d7de17bf44a886900ecb834953408dae8aaf90465ce91c1dd" +dependencies = [ + "aws-credential-types", + "aws-sigv4", + "aws-smithy-async", + "aws-smithy-eventstream", + "aws-smithy-http", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-types", + "bytes", + "fastrand", + "http 0.2.12", + "http-body 0.4.6", + "percent-encoding", + "pin-project-lite", + "tracing", + "uuid", +] [[package]] -name = "getrandom" -version = "0.2.15" +name = "aws-sdk-s3" +version = "1.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +checksum = "2ecec5514e9d9c76c5e9489ca65ab9055ae0b3c49da3a1afd452c57cb68734fb" dependencies = [ - "cfg-if", - "libc", - "wasi", + "ahash 0.8.11", + "aws-credential-types", + "aws-runtime", + "aws-sigv4", + "aws-smithy-async", + "aws-smithy-checksums", + "aws-smithy-eventstream", + "aws-smithy-http", + "aws-smithy-json", + "aws-smithy-runtime", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-smithy-xml", + "aws-types", + "bytes", + "fastrand", + "hex", + "hmac", + "http 0.2.12", + "http-body 0.4.6", + "lru", + "once_cell", + "percent-encoding", + "regex-lite", + "sha2", + "tracing", + "url", ] [[package]] -name = "hashbrown" -version = "0.12.3" +name = "aws-sigv4" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +checksum = "31eed8d45759b2c5fe7fd304dd70739060e9e0de509209036eabea14d0720cce" dependencies = [ - "ahash", + "aws-credential-types", + "aws-smithy-eventstream", + "aws-smithy-http", + "aws-smithy-runtime-api", + "aws-smithy-types", + "bytes", + "crypto-bigint 0.5.5", + "form_urlencoded", + "hex", + "hmac", + "http 0.2.12", + "http 1.1.0", + "once_cell", + "p256", + "percent-encoding", + "ring", + "sha2", + "subtle", + "time", + "tracing", + "zeroize", ] [[package]] -name = "libc" -version = "0.2.155" +name = "aws-smithy-async" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "62220bc6e97f946ddd51b5f1361f78996e704677afc518a4ff66b7a72ea1378c" +dependencies = [ + "futures-util", + "pin-project-lite", + "tokio", +] [[package]] -name = "once_cell" -version = "1.19.0" +name = "aws-smithy-checksums" +version = "0.60.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "c5b30ea96823b8b25fb6471643a516e1bd475fd5575304e6240aea179f213216" +dependencies = [ + "aws-smithy-http", + "aws-smithy-types", + "bytes", + "crc32c", + "crc32fast", + "hex", + "http 0.2.12", + "http-body 0.4.6", + "md-5", + "pin-project-lite", + "sha1", + "sha2", + "tracing", +] [[package]] -name = "proc-macro2" -version = "1.0.86" +name = "aws-smithy-eventstream" +version = "0.60.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "e6363078f927f612b970edf9d1903ef5cef9a64d1e8423525ebb1f0a1633c858" dependencies = [ - "unicode-ident", + "aws-smithy-types", + "bytes", + "crc32fast", ] [[package]] -name = "ptr_meta" -version = "0.1.4" +name = "aws-smithy-http" +version = "0.60.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" +checksum = "4a7de001a1b9a25601016d8057ea16e31a45fdca3751304c8edf4ad72e706c08" dependencies = [ - "ptr_meta_derive", + "aws-smithy-eventstream", + "aws-smithy-runtime-api", + "aws-smithy-types", + "bytes", + "bytes-utils", + "futures-core", + "http 0.2.12", + "http-body 0.4.6", + "once_cell", + "percent-encoding", + "pin-project-lite", + "pin-utils", + "tracing", ] [[package]] -name = "ptr_meta_derive" -version = "0.1.4" +name = "aws-smithy-json" +version = "0.60.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" +checksum = "4683df9469ef09468dad3473d129960119a0d3593617542b7d52086c8486f2d6" dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", + "aws-smithy-types", ] [[package]] -name = "quote" -version = "1.0.36" +name = "aws-smithy-runtime" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "db83b08939838d18e33b5dbaf1a0f048f28c10bd28071ab7ce6f245451855414" dependencies = [ - "proc-macro2", + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-runtime-api", + "aws-smithy-types", + "bytes", + "fastrand", + "h2", + "http 0.2.12", + "http-body 0.4.6", + "http-body 1.0.0", + "httparse", + "hyper", + "hyper-rustls", + "once_cell", + "pin-project-lite", + "pin-utils", + "rustls", + "tokio", + "tracing", ] [[package]] -name = "radium" -version = "0.7.0" +name = "aws-smithy-runtime-api" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" +checksum = "1b570ea39eb95bd32543f6e4032bce172cb6209b9bc8c83c770d08169e875afc" +dependencies = [ + "aws-smithy-async", + "aws-smithy-types", + "bytes", + "http 0.2.12", + "http 1.1.0", + "pin-project-lite", + "tokio", + "tracing", + "zeroize", +] [[package]] -name = "rend" -version = "0.4.2" +name = "aws-smithy-types" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71fe3824f5629716b1589be05dacd749f6aa084c87e00e016714a8cdfccc997c" +checksum = "cfe321a6b21f5d8eabd0ade9c55d3d0335f3c3157fc2b3e87f05f34b539e4df5" dependencies = [ - "bytecheck", + "base64-simd", + "bytes", + "bytes-utils", + "futures-core", + "http 0.2.12", + "http 1.1.0", + "http-body 0.4.6", + "http-body 1.0.0", + "http-body-util", + "itoa", + "num-integer", + "pin-project-lite", + "pin-utils", + "ryu", + "serde", + "time", + "tokio", + "tokio-util", ] [[package]] -name = "rkyv" -version = "0.7.44" +name = "aws-smithy-xml" +version = "0.60.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cba464629b3394fc4dbc6f940ff8f5b4ff5c7aef40f29166fd4ad12acbc99c0" +checksum = "d123fbc2a4adc3c301652ba8e149bf4bc1d1725affb9784eb20c953ace06bf55" dependencies = [ - "bitvec", - "bytecheck", - "bytes", - "hashbrown", - "ptr_meta", - "rend", - "rkyv_derive", - "seahash", - "tinyvec", - "uuid", + "xmlparser", ] [[package]] -name = "rkyv_derive" -version = "0.7.44" +name = "aws-types" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7dddfff8de25e6f62b9d64e6e432bf1c6736c57d20323e15ee10435fbda7c65" +checksum = "2009a9733865d0ebf428a314440bbe357cc10d0c16d86a8e15d32e9b47c1e80e" dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", + "aws-credential-types", + "aws-smithy-async", + "aws-smithy-runtime-api", + "aws-smithy-types", + "rustc_version", + "tracing", ] [[package]] -name = "rpc" -version = "0.1.0" +name = "backtrace" +version = "0.3.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" dependencies = [ - "proc-macro2", - "quote", - "rkyv", - "rpc-macro", - "syn 2.0.68", + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", ] [[package]] -name = "rpc-macro" -version = "0.1.0" +name = "base16ct" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "base64-simd" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "339abbe78e73178762e23bea9dfd08e697eb3f3301cd4be981c0f78ba5859195" dependencies = [ - "proc-macro2", - "quote", - "rpc-parser", - "syn 2.0.68", + "outref", + "vsimd", ] [[package]] -name = "rpc-parser" -version = "0.1.0" +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" dependencies = [ - "syn 2.0.68", + "funty", + "radium", + "tap", + "wyz", ] [[package]] -name = "seahash" -version = "4.1.0" +name = "block-buffer" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] [[package]] -name = "simdutf8" -version = "0.1.4" +name = "bytecheck" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" +checksum = "23cdc57ce23ac53c931e88a43d06d070a6fd142f2617be5855eb75efc9beb1c2" +dependencies = [ + "bytecheck_derive", + "ptr_meta", + "simdutf8", +] [[package]] -name = "syn" -version = "1.0.109" +name = "bytecheck_derive" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +checksum = "3db406d29fbcd95542e92559bed4d8ad92636d1ca8b3b72ede10b4bcc010e659" dependencies = [ "proc-macro2", "quote", - "unicode-ident", + "syn 1.0.109", ] [[package]] -name = "syn" -version = "2.0.68" +name = "bytes" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" + +[[package]] +name = "bytes-utils" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dafe3a8757b027e2be6e4e5601ed563c55989fcf1546e933c66c8eb3a058d35" dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "bytes", + "either", ] [[package]] -name = "tap" -version = "1.0.1" +name = "cc" +version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" +checksum = "c891175c3fb232128f48de6590095e59198bbeb8620c310be349bfc3afd12c7b" [[package]] -name = "tinyvec" -version = "1.6.1" +name = "cfg-if" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c55115c6fbe2d2bef26eb09ad74bde02d8255476fc0c7b515ef09fbb35742d82" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" dependencies = [ - "tinyvec_macros", + "core-foundation-sys", + "libc", ] [[package]] -name = "tinyvec_macros" -version = "0.1.1" +name = "core-foundation-sys" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] -name = "unicode-ident" -version = "1.0.12" +name = "cpufeatures" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +dependencies = [ + "libc", +] [[package]] -name = "uuid" -version = "1.9.1" +name = "crc32c" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de17fd2f7da591098415cff336e12965a28061ddace43b59cb3c430179c9439" +checksum = "3a47af21622d091a8f0fb295b88bc886ac74efcc613efc19f5d0b21de5c89e47" +dependencies = [ + "rustc_version", +] [[package]] -name = "version_check" -version = "0.9.4" +name = "crc32fast" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +dependencies = [ + "cfg-if", +] [[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" +name = "crypto-bigint" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" +dependencies = [ + "generic-array", + "rand_core", + "subtle", + "zeroize", +] [[package]] -name = "wyz" -version = "0.5.1" +name = "crypto-bigint" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ - "tap", + "rand_core", + "subtle", ] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "database" +version = "0.1.0" +dependencies = [ + "anyhow", + "aws-sdk-s3", + "document", + "migration", + "quick_cache", + "rkyv", + "rusqlite", + "tokio", +] + +[[package]] +name = "der" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" +dependencies = [ + "const-oid", + "zeroize", +] + +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", + "subtle", +] + +[[package]] +name = "document" +version = "0.1.0" +dependencies = [ + "anyhow", + "rkyv", + "schema-macro", +] + +[[package]] +name = "ecdsa" +version = "0.14.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" +dependencies = [ + "der", + "elliptic-curve", + "rfc6979", + "signature", +] + +[[package]] +name = "either" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" + +[[package]] +name = "elliptic-curve" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" +dependencies = [ + "base16ct", + "crypto-bigint 0.4.9", + "der", + "digest", + "ff", + "generic-array", + "group", + "pkcs8", + "rand_core", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "fallible-iterator" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" + +[[package]] +name = "fallible-streaming-iterator" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" + +[[package]] +name = "fastrand" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" + +[[package]] +name = "ff" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" +dependencies = [ + "rand_core", + "subtle", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "pin-utils", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "gimli" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" + +[[package]] +name = "group" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" +dependencies = [ + "ff", + "rand_core", + "subtle", +] + +[[package]] +name = "h2" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 0.2.12", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash 0.7.8", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash 0.8.11", + "allocator-api2", +] + +[[package]] +name = "hashlink" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af" +dependencies = [ + "hashbrown 0.14.5", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "http" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +dependencies = [ + "bytes", + "http 0.2.12", + "pin-project-lite", +] + +[[package]] +name = "http-body" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +dependencies = [ + "bytes", + "http 1.1.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "0.14.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f361cde2f109281a220d4307746cdfd5ee3f410da58a70377762396775634b33" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http 0.2.12", + "http-body 0.4.6", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" +dependencies = [ + "futures-util", + "http 0.2.12", + "hyper", + "log", + "rustls", + "rustls-native-certs", + "tokio", + "tokio-rustls", +] + +[[package]] +name = "idna" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "2.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +dependencies = [ + "equivalent", + "hashbrown 0.14.5", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "libsqlite3-sys" +version = "0.28.0" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" + +[[package]] +name = "lru" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" +dependencies = [ + "hashbrown 0.14.5", +] + +[[package]] +name = "md-5" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" +dependencies = [ + "cfg-if", + "digest", +] + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "migration" +version = "0.1.0" +dependencies = [ + "anyhow", + "document", + "schema-0", +] + +[[package]] +name = "miniz_oxide" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.48.0", +] + +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "object" +version = "0.36.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "576dfe1fc8f9df304abb159d767a29d0476f7750fbf8aa7ad07816004a207434" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "outref" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4030760ffd992bef45b0ae3f10ce1aba99e33464c90d14dd7c039884963ddc7a" + +[[package]] +name = "p256" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51f44edd08f51e2ade572f141051021c5af22677e42b7dd28a88155151c33594" +dependencies = [ + "ecdsa", + "elliptic-curve", + "sha2", +] + +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.52.5", +] + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkcs8" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "pkg-config" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "proc-macro2" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "ptr_meta" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "quick_cache" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "347e1a588d1de074eeb3c00eadff93db4db65aeb62aee852b1efd0949fe65b6c" +dependencies = [ + "ahash 0.8.11", + "equivalent", + "hashbrown 0.14.5", + "parking_lot", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "redox_syscall" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex-lite" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a" + +[[package]] +name = "rend" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71fe3824f5629716b1589be05dacd749f6aa084c87e00e016714a8cdfccc997c" +dependencies = [ + "bytecheck", +] + +[[package]] +name = "rfc6979" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" +dependencies = [ + "crypto-bigint 0.4.9", + "hmac", + "zeroize", +] + +[[package]] +name = "ring" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +dependencies = [ + "cc", + "cfg-if", + "getrandom", + "libc", + "spin", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rkyv" +version = "0.7.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cba464629b3394fc4dbc6f940ff8f5b4ff5c7aef40f29166fd4ad12acbc99c0" +dependencies = [ + "bitvec", + "bytecheck", + "bytes", + "hashbrown 0.12.3", + "ptr_meta", + "rend", + "rkyv_derive", + "seahash", + "tinyvec", + "uuid", +] + +[[package]] +name = "rkyv_derive" +version = "0.7.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7dddfff8de25e6f62b9d64e6e432bf1c6736c57d20323e15ee10435fbda7c65" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "rpc" +version = "0.1.0" +dependencies = [ + "database", + "proc-macro2", + "quote", + "rkyv", + "rpc-macro", + "syn 2.0.68", +] + +[[package]] +name = "rpc-macro" +version = "0.1.0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.68", +] + +[[package]] +name = "rusqlite" +version = "0.31.0" +dependencies = [ + "bitflags", + "fallible-iterator", + "fallible-streaming-iterator", + "hashlink", + "libsqlite3-sys", + "smallvec", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + +[[package]] +name = "rustls" +version = "0.21.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" +dependencies = [ + "log", + "ring", + "rustls-webpki", + "sct", +] + +[[package]] +name = "rustls-native-certs" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" +dependencies = [ + "openssl-probe", + "rustls-pemfile", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64", +] + +[[package]] +name = "rustls-webpki" +version = "0.101.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "schannel" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "schema-0" +version = "0.0.1" +dependencies = [ + "document", + "rkyv", + "schema-macro", +] + +[[package]] +name = "schema-macro" +version = "0.1.0" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "sct" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "seahash" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" + +[[package]] +name = "sec1" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" +dependencies = [ + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] + +[[package]] +name = "security-framework" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "semver" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" + +[[package]] +name = "serde" +version = "1.0.203" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.203" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.68", +] + +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "signature" +version = "1.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +dependencies = [ + "digest", + "rand_core", +] + +[[package]] +name = "simdutf8" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "socket2" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + +[[package]] +name = "spki" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "time" +version = "0.3.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +dependencies = [ + "deranged", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tinyvec" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c55115c6fbe2d2bef26eb09ad74bde02d8255476fc0c7b515ef09fbb35742d82" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.38.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "pin-project-lite", + "socket2", + "windows-sys 0.48.0", +] + +[[package]] +name = "tokio-rustls" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.68", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicode-bidi" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-normalization" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "uuid" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5de17fd2f7da591098415cff336e12965a28061ddace43b59cb3c430179c9439" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "vsimd" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c3082ca00d5a5ef149bb8b555a72ae84c9c59f7250f013ac822ac2e49b19c64" + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.5", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +dependencies = [ + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "xmlparser" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66fee0b777b0f5ac1c69bb06d361268faafa61cd4682ae064a171c16c433e9e4" + +[[package]] +name = "zerocopy" +version = "0.7.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.68", +] + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" diff --git a/luda-editor/new-server/rpc/Cargo.toml b/luda-editor/new-server/rpc/Cargo.toml index d141b4b5a..9b36aad47 100644 --- a/luda-editor/new-server/rpc/Cargo.toml +++ b/luda-editor/new-server/rpc/Cargo.toml @@ -9,6 +9,7 @@ rpc-macro = { path = "./macro" } quote = "1.0.29" syn = { version = "2.0.68", features = ["full"] } rkyv = { version = "0.7.44", features = ["validation"] } +database = { path = "../database/database" } [build-dependencies] proc-macro2 = "1.0.86" @@ -16,3 +17,4 @@ rpc-macro = { path = "./macro" } quote = "1.0.29" syn = { version = "2.0.68", features = ["full"] } rkyv = { version = "0.7.44", features = ["validation"] } +database = { path = "../database/database" } diff --git a/luda-editor/new-server/rpc/build.rs b/luda-editor/new-server/rpc/build.rs index ddb00a2a7..9a9311fc4 100644 --- a/luda-editor/new-server/rpc/build.rs +++ b/luda-editor/new-server/rpc/build.rs @@ -45,15 +45,22 @@ fn generate_server_api_files(rpc: &Rpc) { std::fs::write(service_path.join("mod.rs"), service_mod_rs_lines.join("")).unwrap(); for api in &service.apis { - let api_path = service_path.join(format!("{}.rs", api.name)); - if api_path.exists() { + let api_dir = service_path.join(format!("{}", api.name)); + if !api_dir.exists() { + std::fs::create_dir_all(&api_dir).unwrap(); + } + let api_mod_rs = api_dir.join("mod.rs"); + if api_mod_rs.exists() { continue; } let api_name = &api.name; std::fs::write( - &api_path, + &api_mod_rs, format!( - r#"use crate::*; + " + +use crate::*; +use database::schema::*; use rpc::{service_snake_name}::{api_name}::*; pub async fn google_auth( @@ -63,7 +70,7 @@ pub async fn google_auth( ) -> Result {{ todo!() }} -"# +" ), ) .unwrap(); diff --git a/luda-editor/new-server/rpc/macro/Cargo.toml b/luda-editor/new-server/rpc/macro/Cargo.toml index 024a79786..3f0805119 100644 --- a/luda-editor/new-server/rpc/macro/Cargo.toml +++ b/luda-editor/new-server/rpc/macro/Cargo.toml @@ -9,5 +9,4 @@ proc-macro = true [dependencies] quote = "1.0.29" proc-macro2 = "1.0.86" -syn = "2.0.68" -rpc-parser = { path = "../parser" } +syn = { version = "2.0.22", features = ["full"] } diff --git a/luda-editor/new-server/rpc/macro/src/lib.rs b/luda-editor/new-server/rpc/macro/src/lib.rs index 8fabc1072..88c2bbe6f 100644 --- a/luda-editor/new-server/rpc/macro/src/lib.rs +++ b/luda-editor/new-server/rpc/macro/src/lib.rs @@ -1,8 +1,10 @@ +mod parser; + use quote::quote; #[proc_macro] pub fn define_rpc(input: proc_macro::TokenStream) -> proc_macro::TokenStream { - let rpc = syn::parse_macro_input!(input as rpc_parser::Rpc); + let rpc = syn::parse_macro_input!(input as parser::Rpc); let define_rpc_meta = define_rpc_meta(&rpc); let define_rpc_structs_and_mods = define_rpc_structs_and_mods(&rpc); @@ -12,7 +14,7 @@ pub fn define_rpc(input: proc_macro::TokenStream) -> proc_macro::TokenStream { }) } -fn define_rpc_meta(rpc: &rpc_parser::Rpc) -> proc_macro2::TokenStream { +fn define_rpc_meta(rpc: &parser::Rpc) -> proc_macro2::TokenStream { let services = rpc.services.iter().map(|service| { let name: &syn::Ident = &service.name; let snake_case_name = &service.snake_case_name(); @@ -62,16 +64,38 @@ fn define_rpc_meta(rpc: &rpc_parser::Rpc) -> proc_macro2::TokenStream { } } -fn define_rpc_structs_and_mods(rpc: &rpc_parser::Rpc) -> proc_macro2::TokenStream { +fn define_rpc_structs_and_mods(rpc: &parser::Rpc) -> proc_macro2::TokenStream { let services = rpc.services.iter().map(|service| { let service_name = service.snake_case_name(); let apis = service.apis.iter().map(|api| { let api_name = &api.name; let items = api.items.iter().map(|item| { + let mut extra = quote! {}; + if let syn::Item::Enum(enum_item) = item { + if enum_item.ident == "Error" { + extra = quote! { + impl std::fmt::Display for Error { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{:?}", self) + } + } + impl std::error::Error for Error {} + + impl From for Error { + fn from(e: database::Error) -> Self { + Error::InternalServerError { + err: format!("{e}"), + } + } + } + }; + } + } quote! { #[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)] #[archive(check_bytes)] #item + #extra } }); quote! { diff --git a/luda-editor/new-server/rpc/parser/src/lib.rs b/luda-editor/new-server/rpc/macro/src/parser.rs similarity index 77% rename from luda-editor/new-server/rpc/parser/src/lib.rs rename to luda-editor/new-server/rpc/macro/src/parser.rs index c97795355..cf3054fa9 100644 --- a/luda-editor/new-server/rpc/parser/src/lib.rs +++ b/luda-editor/new-server/rpc/macro/src/parser.rs @@ -64,20 +64,23 @@ impl syn::parse::Parse for Api { let mut items = Vec::new(); while !content.is_empty() { let mut item: syn::Item = content.parse()?; - let span = item.span(); match &mut item { - syn::Item::Const(x) => x.vis = syn::Visibility::Public(syn::token::Pub(span)), + syn::Item::Const(x) => x.vis = syn::Visibility::Public(syn::token::Pub(x.span())), syn::Item::Enum(x) => { if x.ident.to_string() == "Error" { - let mut fields = Punctuated::new(); - fields.push(syn::parse_quote!(error: String)); + x.attrs.push(syn::parse_quote!(#[derive(Debug)])); + x.variants.push(syn::Variant { attrs: Vec::new(), - ident: Ident::new("InternalServerError", span), + ident: Ident::new("InternalServerError", x.span()), fields: syn::Fields::Named(syn::FieldsNamed { - brace_token: syn::token::Brace(span), - named: fields, + brace_token: syn::token::Brace(x.span()), + named: { + let mut fields = Punctuated::new(); + fields.push(syn::parse_quote!(err: String)); + fields + }, }), discriminant: None, }); @@ -88,23 +91,28 @@ impl syn::parse::Parse for Api { "Enums must have at least one variant", )); } - x.vis = syn::Visibility::Public(syn::token::Pub(span)) + x.vis = syn::Visibility::Public(syn::token::Pub(x.span())) } - syn::Item::ExternCrate(x) => x.vis = syn::Visibility::Public(syn::token::Pub(span)), - syn::Item::Fn(x) => x.vis = syn::Visibility::Public(syn::token::Pub(span)), - syn::Item::Mod(x) => x.vis = syn::Visibility::Public(syn::token::Pub(span)), - syn::Item::Static(x) => x.vis = syn::Visibility::Public(syn::token::Pub(span)), + syn::Item::ExternCrate(x) => { + x.vis = syn::Visibility::Public(syn::token::Pub(x.span())) + } + syn::Item::Fn(x) => x.vis = syn::Visibility::Public(syn::token::Pub(x.span())), + syn::Item::Mod(x) => x.vis = syn::Visibility::Public(syn::token::Pub(x.span())), + syn::Item::Static(x) => x.vis = syn::Visibility::Public(syn::token::Pub(x.span())), syn::Item::Struct(x) => { - x.vis = syn::Visibility::Public(syn::token::Pub(span)); + x.vis = syn::Visibility::Public(syn::token::Pub(x.span())); + let span = x.span(); x.fields.iter_mut().for_each(|field| { field.vis = syn::Visibility::Public(syn::token::Pub(span)); }); } - syn::Item::Trait(x) => x.vis = syn::Visibility::Public(syn::token::Pub(span)), - syn::Item::TraitAlias(x) => x.vis = syn::Visibility::Public(syn::token::Pub(span)), - syn::Item::Type(x) => x.vis = syn::Visibility::Public(syn::token::Pub(span)), - syn::Item::Union(x) => x.vis = syn::Visibility::Public(syn::token::Pub(span)), - syn::Item::Use(x) => x.vis = syn::Visibility::Public(syn::token::Pub(span)), + syn::Item::Trait(x) => x.vis = syn::Visibility::Public(syn::token::Pub(x.span())), + syn::Item::TraitAlias(x) => { + x.vis = syn::Visibility::Public(syn::token::Pub(x.span())) + } + syn::Item::Type(x) => x.vis = syn::Visibility::Public(syn::token::Pub(x.span())), + syn::Item::Union(x) => x.vis = syn::Visibility::Public(syn::token::Pub(x.span())), + syn::Item::Use(x) => x.vis = syn::Visibility::Public(syn::token::Pub(x.span())), _ => todo!(), } items.push(item); diff --git a/luda-editor/new-server/rpc/parser/.gitignore b/luda-editor/new-server/rpc/parser/.gitignore deleted file mode 100644 index df2ad90f4..000000000 --- a/luda-editor/new-server/rpc/parser/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -# Created by https://www.toptal.com/developers/gitignore/api/rust -# Edit at https://www.toptal.com/developers/gitignore?templates=rust - -### Rust ### -# Generated by Cargo -# will have compiled files and executables -debug/ -target/ - -# These are backup files generated by rustfmt -**/*.rs.bk - -# MSVC Windows builds of rustc generate these, which store debugging information -*.pdb - -# End of https://www.toptal.com/developers/gitignore/api/rust diff --git a/luda-editor/new-server/rpc/parser/Cargo.lock b/luda-editor/new-server/rpc/parser/Cargo.lock deleted file mode 100644 index b278daaec..000000000 --- a/luda-editor/new-server/rpc/parser/Cargo.lock +++ /dev/null @@ -1,47 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "proc-macro2" -version = "1.0.63" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rpc-macro" -version = "0.1.0" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "syn" -version = "2.0.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2efbeae7acf4eabd6bcdcbd11c92f45231ddda7539edc7806bd1a04a03b24616" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "unicode-ident" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" diff --git a/luda-editor/new-server/rpc/parser/Cargo.toml b/luda-editor/new-server/rpc/parser/Cargo.toml deleted file mode 100644 index 42a9e96d2..000000000 --- a/luda-editor/new-server/rpc/parser/Cargo.toml +++ /dev/null @@ -1,7 +0,0 @@ -[package] -edition = "2021" -name = "rpc-parser" -version = "0.1.0" - -[dependencies] -syn = { version = "2.0.22", features = ["full"] } diff --git a/luda-editor/new-server/rpc/parser/src/server.rs b/luda-editor/new-server/rpc/parser/src/server.rs deleted file mode 100644 index 23df7241f..000000000 --- a/luda-editor/new-server/rpc/parser/src/server.rs +++ /dev/null @@ -1,63 +0,0 @@ -use crate::*; -use proc_macro2::TokenStream; -use quote::quote; - -impl Rpc { - pub fn server_handler(&self) -> TokenStream { - let mut api_index = 0; - let rpc_structs = self.services.iter().map(|service| { - let service_name = &service.name; - let chunks = service.apis.iter().map(|api| { - let this_api_index = api_index; - api_index += 1; - - let api_name = &api.name; - - quote! { - #this_api_index => { - let Ok(request) = rkyv::validation::validators::check_archived_root::< - api::#service_name::#api_name::Request, - >(in_payload) else { - return Err(anyhow::anyhow!("Failed to validate packet")); - }; - match api::#service_name::#api_name::#api_name(request, db, session) - .await - .and_then(|response| Ok(rkyv::to_bytes::<_, 64>(&response)?)) - { - Ok(bytes) => (bytes.into_vec(), Status::Ok), - Err(error) => { - eprintln!("Error on #api_name: {:?}", error); - (Vec::new(), Status::ServerError) - } - } - } - } - }); - quote! { - #(#chunks)* - } - }); - - quote! { - #(#rpc_structs)* - } - } -} - -// 0 => { -// let Ok(request) = rkyv::validation::validators::check_archived_root::< -// api::google_auth::Request, -// >(in_payload) else { -// return Err(anyhow::anyhow!("Failed to validate packet")); -// }; -// match api::google_auth::google_auth(request, db, session) -// .await -// .and_then(|response| Ok(rkyv::to_bytes::<_, 64>(&response)?)) -// { -// Ok(bytes) => (bytes.into_vec(), Status::Ok), -// Err(error) => { -// eprintln!("Error on google_auth: {:?}", error); -// (Vec::new(), Status::ServerError) -// } -// } -// } diff --git a/luda-editor/new-server/rpc/src/data/cg.rs b/luda-editor/new-server/rpc/src/data/cg.rs deleted file mode 100644 index 54ee5f90c..000000000 --- a/luda-editor/new-server/rpc/src/data/cg.rs +++ /dev/null @@ -1,65 +0,0 @@ -use namui_type::*; - -#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] -pub struct CgFile { - /// TODO: Rename id as checksum. real id is name. - pub id: Uuid, - pub name: String, - pub parts: Vec, - pub width_per_height: namui_type::Per, -} - -#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] -pub struct CgPart { - pub name: String, - pub selection_type: PartSelectionType, - pub variants: Vec, -} - -#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] -pub struct CgPartVariant { - /// TODO: Rename id as checksum. real id is name. - pub id: Uuid, - pub name: String, - pub rect: Rect, - pub blend_mode: CgPartVariantBlendMode, -} - -#[derive(Debug, Clone, Copy, serde::Serialize, serde::Deserialize)] -pub enum CgPartVariantBlendMode { - PassThrough, - Normal, - Dissolve, - Darken, - Multiply, - ColorBurn, - LinearBurn, - DarkerColor, - Lighten, - Screen, - ColorDodge, - LinearDodge, - LighterColor, - Overlay, - SoftLight, - HardLight, - VividLight, - LinearLight, - PinLight, - HardMix, - Difference, - Exclusion, - Subtract, - Divide, - Hue, - Saturation, - Color, - Luminosity, -} - -#[derive(Debug, Clone, Copy, serde::Serialize, serde::Deserialize, PartialEq)] -pub enum PartSelectionType { - AlwaysOn, - Single, - Multi, -} diff --git a/luda-editor/new-server/rpc/src/data/cut/mod.rs b/luda-editor/new-server/rpc/src/data/cut/mod.rs deleted file mode 100644 index 3f42349ec..000000000 --- a/luda-editor/new-server/rpc/src/data/cut/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -mod previous; -mod v5; - -use previous::*; -pub use v5::*; diff --git a/luda-editor/new-server/rpc/src/data/cut/previous/mod.rs b/luda-editor/new-server/rpc/src/data/cut/previous/mod.rs deleted file mode 100644 index 197f689a1..000000000 --- a/luda-editor/new-server/rpc/src/data/cut/previous/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![allow(dead_code)] - -pub mod v0; -pub mod v1; -pub mod v2; -pub mod v3; -pub mod v4; diff --git a/luda-editor/new-server/rpc/src/data/cut/previous/v0.rs b/luda-editor/new-server/rpc/src/data/cut/previous/v0.rs deleted file mode 100644 index 39d0939be..000000000 --- a/luda-editor/new-server/rpc/src/data/cut/previous/v0.rs +++ /dev/null @@ -1,33 +0,0 @@ -use crate::Uuid; - -#[migration::version(0)] -#[derive(Debug, Clone, Default)] -pub struct Cut { - id: Uuid, - /// The text that the character speaks in this cut. - pub line: String, - pub character_id: Option, - pub screen_image_ids: [Option; 5], -} - -impl Cut { - pub fn new(id: Uuid) -> Self { - Self { - id, - line: String::new(), - character_id: None, - screen_image_ids: [None; 5], - } - } - pub fn id(&self) -> Uuid { - self.id - } - pub fn duplicate(&self, id: Uuid) -> Self { - Self { - id, - line: self.line.clone(), - character_id: self.character_id, - screen_image_ids: self.screen_image_ids, - } - } -} diff --git a/luda-editor/new-server/rpc/src/data/cut/previous/v1.rs b/luda-editor/new-server/rpc/src/data/cut/previous/v1.rs deleted file mode 100644 index 7149db9d9..000000000 --- a/luda-editor/new-server/rpc/src/data/cut/previous/v1.rs +++ /dev/null @@ -1,124 +0,0 @@ -use super::*; -use crate::data::ScreenImage; -use crate::Uuid; - -pub type ScreenImages = [Option; 5]; - -#[migration::version(1)] -#[derive(Debug, Clone, Default)] -pub struct Cut { - id: Uuid, - /// The text that the character speaks in this cut. - pub line: String, - pub character_id: Option, - pub screen_images: ScreenImages, -} - -impl Cut { - pub fn migrate(previous: v0::Cut) -> Self { - Self { - id: previous.id(), - line: previous.line, - character_id: previous.character_id, - screen_images: previous - .screen_image_ids - .map(|image_id| image_id.map(ScreenImage::new)), - } - } - pub fn new(id: Uuid) -> Self { - Self { - id, - line: String::new(), - character_id: None, - screen_images: [None, None, None, None, None], - } - } - pub fn id(&self) -> Uuid { - self.id - } - pub fn duplicate(&self, id: Uuid) -> Self { - Self { - id, - line: self.line.clone(), - character_id: self.character_id, - screen_images: self.screen_images, - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_migrate() { - let previous = v0::Cut::new(Uuid::new_v4()); - let previous_id = previous.id(); - let current = Cut::migrate(previous); - assert_eq!(current.id(), previous_id); - } - - #[test] - fn test_serialize() { - let id = Uuid::new_v4(); - let cut = Cut::new(id); - - let serialized = bincode::serialize(&cut).unwrap(); - let expected = std::iter::empty::() - // id (24 bytes): uuid length (8 bytes) + uuid (16 bytes) - .chain([16, 0, 0, 0, 0, 0, 0, 0]) // uuid length (8 bytes) - .chain(*id.as_bytes()) // uuid (16 bytes) - // line (8 bytes): string length (8 bytes) + string (0 bytes) - .chain([0, 0, 0, 0, 0, 0, 0, 0]) // string length (8 bytes) - // character_id (1 bytes): none (1 byte) - .chain([0]) // none (1 byte) - // screen_images (5 bytes): none (1 byte) * 5 - .chain([0, 0, 0, 0, 0]) // none * 5 - .collect::>(); - - assert_eq!(serialized, expected); - } - - #[test] - fn test_deserialize() { - let id = Uuid::new_v4(); - let bytes = std::iter::empty::() - // id (24 bytes): uuid length (8 bytes) + uuid (16 bytes) - .chain([16, 0, 0, 0, 0, 0, 0, 0]) // uuid length (8 bytes) - .chain(*id.as_bytes()) // uuid (16 bytes) - // line (8 bytes): string length (8 bytes) + string (0 bytes) - .chain([0, 0, 0, 0, 0, 0, 0, 0]) // string length (8 bytes) - // character_id (1 bytes): none (1 byte) - .chain([0]) // none (1 byte) - // screen_images (5 bytes): none (1 byte) * 5 - .chain([0, 0, 0, 0, 0]) // none * 5 - .collect::>(); - - let cut: Cut = migration::Migration::deserialize(&bytes, 1).unwrap(); - assert_eq!(cut.id(), id); - } - - #[test] - fn test_deserialize_migrate() { - let id = Uuid::new_v4(); - // id: Uuid, - // /// The text that the character speaks in this cut. - // pub line: String, - // pub character_id: Option, - // pub screen_image_ids: [Option; 5], - let bytes = std::iter::empty::() - // id (24 bytes): uuid length (8 bytes) + uuid (16 bytes) - .chain([16, 0, 0, 0, 0, 0, 0, 0]) // uuid length (8 bytes) - .chain(*id.as_bytes()) // uuid (16 bytes) - // line (8 bytes): string length (8 bytes) + string (0 bytes) - .chain([0, 0, 0, 0, 0, 0, 0, 0]) // string length (8 bytes) - // character_id (1 bytes): none (1 byte) - .chain([0]) // none (1 byte) - // screen_image_ids (5 bytes): none (1 byte) * 5 - .chain([0, 0, 0, 0, 0]) // none * 5 - .collect::>(); - - let cut: Cut = migration::Migration::deserialize(&bytes, 0).unwrap(); - assert_eq!(cut.id(), id); - } -} diff --git a/luda-editor/new-server/rpc/src/data/cut/previous/v2.rs b/luda-editor/new-server/rpc/src/data/cut/previous/v2.rs deleted file mode 100644 index eb164c53a..000000000 --- a/luda-editor/new-server/rpc/src/data/cut/previous/v2.rs +++ /dev/null @@ -1,50 +0,0 @@ -use super::*; -use crate::data::screen_graphic; -use crate::Uuid; - -pub type ScreenImages = [Option; 5]; - -#[migration::version(2)] -#[derive(Debug, Clone, Default)] -pub struct Cut { - id: Uuid, - /// The text that the character speaks in this cut. - pub line: String, - pub character_name: String, - pub screen_images: ScreenImages, -} - -impl Cut { - pub fn migrate(previous: v1::Cut) -> Self { - Self { - id: previous.id(), - line: previous.line, - character_name: "".to_string(), - screen_images: previous.screen_images.map(|image| { - image.map(|image| screen_graphic::previous::v0::ScreenImage { - id: image.id, - circumscribed: image.circumscribed, - }) - }), - } - } - pub fn new(id: Uuid) -> Self { - Self { - id, - line: String::new(), - character_name: String::new(), - screen_images: [None, None, None, None, None], - } - } - pub fn id(&self) -> Uuid { - self.id - } - pub fn duplicate(&self, id: Uuid) -> Self { - Self { - id, - line: self.line.clone(), - character_name: self.character_name.clone(), - screen_images: self.screen_images, - } - } -} diff --git a/luda-editor/new-server/rpc/src/data/cut/previous/v3.rs b/luda-editor/new-server/rpc/src/data/cut/previous/v3.rs deleted file mode 100644 index 8b4528466..000000000 --- a/luda-editor/new-server/rpc/src/data/cut/previous/v3.rs +++ /dev/null @@ -1,52 +0,0 @@ -use super::*; -use crate::data::screen_graphic; -use crate::Uuid; - -#[migration::version(3)] -#[derive(Debug, Clone, Default)] -pub struct Cut { - id: Uuid, - /// The text that the character speaks in this cut. - pub line: String, - pub character_name: String, - pub screen_images: Vec, -} - -impl Cut { - pub fn migrate(previous: v2::Cut) -> Self { - Self { - id: previous.id(), - line: previous.line, - character_name: "".to_string(), - screen_images: previous - .screen_images - .into_iter() - .filter_map(|image| { - image.map(|image| screen_graphic::previous::v0::ScreenImage { - id: image.id, - circumscribed: image.circumscribed, - }) - }) - .collect(), - } - } - pub fn new(id: Uuid) -> Self { - Self { - id, - line: String::new(), - character_name: String::new(), - screen_images: Vec::new(), - } - } - pub fn id(&self) -> Uuid { - self.id - } - pub fn duplicate(&self, id: Uuid) -> Self { - Self { - id, - line: self.line.clone(), - character_name: self.character_name.clone(), - screen_images: self.screen_images.clone(), - } - } -} diff --git a/luda-editor/new-server/rpc/src/data/cut/previous/v4.rs b/luda-editor/new-server/rpc/src/data/cut/previous/v4.rs deleted file mode 100644 index a5abec172..000000000 --- a/luda-editor/new-server/rpc/src/data/cut/previous/v4.rs +++ /dev/null @@ -1,47 +0,0 @@ -use super::*; -use crate::data::screen_graphic; -use crate::Uuid; - -#[migration::version(4)] -#[derive(Debug, Clone, Default)] -pub struct Cut { - id: Uuid, - /// The text that the character speaks in this cut. - pub line: String, - pub character_name: String, - pub screen_graphics: Vec, -} - -impl Cut { - pub fn migrate(previous: v3::Cut) -> Self { - Self { - id: previous.id(), - line: previous.line, - character_name: previous.character_name, - screen_graphics: previous - .screen_images - .into_iter() - .map(screen_graphic::previous::v0::ScreenGraphic::Image) - .collect(), - } - } - pub fn new(id: Uuid) -> Self { - Self { - id, - line: String::new(), - character_name: String::new(), - screen_graphics: Vec::new(), - } - } - pub fn id(&self) -> Uuid { - self.id - } - pub fn duplicate(&self, id: Uuid) -> Self { - Self { - id, - line: self.line.clone(), - character_name: self.character_name.clone(), - screen_graphics: self.screen_graphics.clone(), - } - } -} diff --git a/luda-editor/new-server/rpc/src/data/cut/v5.rs b/luda-editor/new-server/rpc/src/data/cut/v5.rs deleted file mode 100644 index 5ea3864e3..000000000 --- a/luda-editor/new-server/rpc/src/data/cut/v5.rs +++ /dev/null @@ -1,48 +0,0 @@ -use super::*; -use crate::data::ScreenGraphic; -use crate::Uuid; - -#[migration::version(5)] -#[derive(Debug, Clone, Default, PartialEq)] -pub struct Cut { - pub id: Uuid, - - /// The text that the character speaks in this cut. - pub line: String, - pub character_name: String, - /// IndexId is not sg's id. it's index id. - pub screen_graphics: Vec<(IndexId, ScreenGraphic)>, -} - -type IndexId = Uuid; - -impl Cut { - pub fn migrate(previous: v4::Cut) -> Self { - Self { - id: previous.id(), - line: previous.line, - character_name: previous.character_name, - screen_graphics: previous - .screen_graphics - .into_iter() - .map(|sg| (Uuid::new_v4(), ScreenGraphic::migrate(sg))) - .collect(), - } - } - pub fn new(id: Uuid) -> Self { - Self { - id, - line: String::new(), - character_name: String::new(), - screen_graphics: vec![], - } - } - pub fn duplicate(&self, id: Uuid) -> Self { - Self { - id, - line: self.line.clone(), - character_name: self.character_name.clone(), - screen_graphics: self.screen_graphics.clone(), - } - } -} diff --git a/luda-editor/new-server/rpc/src/data/cut_update_action.rs b/luda-editor/new-server/rpc/src/data/cut_update_action.rs deleted file mode 100644 index 93131861e..000000000 --- a/luda-editor/new-server/rpc/src/data/cut_update_action.rs +++ /dev/null @@ -1,264 +0,0 @@ -use super::*; -use crate::simple_error_impl; -use namui_type::{Angle, Uuid}; -use std::marker::PhantomData; - -#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] -pub enum CutUpdateAction { - ChangeCharacterName { - name: String, - }, - ChangeCutLine { - line: String, - }, - PushScreenGraphic { - graphic_index: Uuid, - screen_graphic: ScreenGraphic, - }, - ChangeCgKeepCircumscribed { - graphic_index: Uuid, - cg: ScreenCg, - }, - UnselectCgPart { - graphic_index: Uuid, - cg_part_name: String, - }, - TurnOffCgPartVariant { - graphic_index: Uuid, - cg_part_name: String, - cg_part_variant_name: String, - }, - TurnOnCgPartVariant { - graphic_index: Uuid, - cg_part_name: String, - cg_part_variant_name: String, - }, - UpdateCircumscribed { - graphic_index: Uuid, - circumscribed: Circumscribed, - }, - ChangeGraphicCircumscribed { - graphic_index: Uuid, - circumscribed: Circumscribed, - }, - GraphicFitContain { - graphic_index: Uuid, - image_width_per_height_ratio: f32, - }, - GraphicFitCover { - graphic_index: Uuid, - image_width_per_height_ratio: f32, - }, - SetCut { - cut: Cut, - }, - DeleteGraphic { - graphic_index: Uuid, - }, - ChangeGraphicOrder(ChangeGraphicOrderAction), - UpdateGraphicRotation { - graphic_index: Uuid, - rotation: Angle, - }, -} -#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] -pub struct ChangeGraphicOrderAction { - pub graphic_index: Uuid, - pub after_graphic_index: Option, - prevent_direct_creation: PhantomData<()>, -} -impl ChangeGraphicOrderAction { - pub fn new( - graphic_index: Uuid, - after_graphic_index: Option, - ) -> Result { - if after_graphic_index == Some(graphic_index) { - return Err(ChangeGraphicOrderActionCreateError::MoveAfterItself); - } - Ok(Self { - graphic_index, - after_graphic_index, - prevent_direct_creation: PhantomData, - }) - } -} -impl From for CutUpdateAction { - fn from(value: ChangeGraphicOrderAction) -> Self { - Self::ChangeGraphicOrder(value) - } -} -simple_error_impl!(ChangeGraphicOrderActionCreateError); -#[derive(Debug)] -pub enum ChangeGraphicOrderActionCreateError { - MoveAfterItself, -} - -impl CutUpdateAction { - pub fn update(self, cut: &mut crate::data::Cut) { - match self { - CutUpdateAction::ChangeCharacterName { name } => { - cut.character_name = name; - } - CutUpdateAction::ChangeCutLine { line } => { - cut.line = line; - } - CutUpdateAction::PushScreenGraphic { - screen_graphic, - graphic_index, - } => { - cut.screen_graphics.push((graphic_index, screen_graphic)); - } - CutUpdateAction::ChangeCgKeepCircumscribed { graphic_index, cg } => { - update_cg(cut, graphic_index, |self_cg| { - *self_cg = cg; - }); - } - CutUpdateAction::UnselectCgPart { - graphic_index, - cg_part_name, - } => update_cg_part(cut, graphic_index, cg_part_name, |part| part.unselect()), - CutUpdateAction::TurnOffCgPartVariant { - graphic_index, - cg_part_name, - cg_part_variant_name, - } => update_cg_part(cut, graphic_index, cg_part_name, |part| { - part.turn_off(cg_part_variant_name) - }), - CutUpdateAction::TurnOnCgPartVariant { - graphic_index, - cg_part_name, - cg_part_variant_name, - } => update_cg_part(cut, graphic_index, cg_part_name, |part| { - part.turn_on(cg_part_variant_name) - }), - CutUpdateAction::UpdateCircumscribed { - graphic_index, - circumscribed, - } => update_graphic(cut, graphic_index, |graphic| { - graphic.set_circumscribed(circumscribed) - }), - CutUpdateAction::ChangeGraphicCircumscribed { - graphic_index, - circumscribed, - } => { - update_graphic(cut, graphic_index, |graphic| { - graphic.set_circumscribed(circumscribed); - }); - } - CutUpdateAction::GraphicFitContain { - graphic_index, - image_width_per_height_ratio, - } => update_graphic(cut, graphic_index, |graphic| { - let screen_width_per_height_ratio = 4.0 / 3.0; - let radius = if image_width_per_height_ratio > screen_width_per_height_ratio { - let width = 4.0 / 5.0; - let height = width / image_width_per_height_ratio; - Xy::new(width, height).length() - } else { - let height = 3.0 / 5.0; - let width = height * image_width_per_height_ratio; - Xy::new(width, height).length() - }; - - let circumscribed = graphic.circumscribed_mut(); - circumscribed.center_xy = Xy::single(50.percent()); - circumscribed.radius = Percent::from(radius); - }), - CutUpdateAction::GraphicFitCover { - graphic_index, - image_width_per_height_ratio, - } => update_graphic(cut, graphic_index, |graphic| { - let screen_width_per_height_ratio = 4.0 / 3.0; - let radius = if image_width_per_height_ratio > screen_width_per_height_ratio { - let height = 3.0 / 5.0; - let width = height * image_width_per_height_ratio; - Xy::new(width, height).length() - } else { - let width = 4.0 / 5.0; - let height = width / image_width_per_height_ratio; - Xy::new(width, height).length() - }; - - let circumscribed = graphic.circumscribed_mut(); - circumscribed.center_xy = Xy::single(50.percent()); - circumscribed.radius = Percent::from(radius); - }), - CutUpdateAction::SetCut { cut: _cut } => { - *cut = _cut; - } - CutUpdateAction::DeleteGraphic { graphic_index } => { - if let Some(position) = cut - .screen_graphics - .iter() - .position(|(index, _)| *index == graphic_index) - { - cut.screen_graphics.remove(position); - } - } - CutUpdateAction::ChangeGraphicOrder(ChangeGraphicOrderAction { - graphic_index, - after_graphic_index, - .. - }) => { - let Some(moving_graphic_position) = cut - .screen_graphics - .iter() - .position(|(index, _)| index == &graphic_index) - else { - return; - }; - let moving_graphic = cut.screen_graphics.remove(moving_graphic_position); - let insert_position = match after_graphic_index { - Some(after_graphic_index) => { - let Some(position) = cut - .screen_graphics - .iter() - .position(|(index, _)| *index == after_graphic_index) - else { - return; - }; - position + 1 - } - None => 0, - }; - - cut.screen_graphics.insert(insert_position, moving_graphic); - } - CutUpdateAction::UpdateGraphicRotation { - graphic_index, - rotation, - } => update_graphic(cut, graphic_index, |graphic| graphic.set_rotation(rotation)), - } - } -} - -fn update_graphic(cut: &mut Cut, graphic_index: Uuid, f: impl FnOnce(&mut ScreenGraphic)) { - if let Some((_, graphic)) = cut - .screen_graphics - .iter_mut() - .find(|(index, _)| *index == graphic_index) - { - f(graphic); - }; -} - -fn update_cg(cut: &mut Cut, graphic_index: Uuid, f: impl FnOnce(&mut ScreenCg)) { - update_graphic(cut, graphic_index, |graphic| { - if let ScreenGraphic::Cg(cg) = graphic { - f(cg); - } - }); -} - -fn update_cg_part( - cut: &mut Cut, - graphic_index: Uuid, - part_name: String, - f: impl FnOnce(&mut ScreenCgPart), -) { - update_cg(cut, graphic_index, |cg| { - if let Some(part) = cg.parts.iter_mut().find(|part| part.name() == part_name) { - f(part); - } - }); -} diff --git a/luda-editor/new-server/rpc/src/data/mod.rs b/luda-editor/new-server/rpc/src/data/mod.rs deleted file mode 100644 index 55ba2fea4..000000000 --- a/luda-editor/new-server/rpc/src/data/mod.rs +++ /dev/null @@ -1,234 +0,0 @@ -mod cg; -mod cut; -mod cut_update_action; -mod screen_graphic; -mod sequence_update_action; - -pub use cg::*; -pub use cut::*; -pub use cut_update_action::*; -use namui_type::{Percent, PercentExt, Uuid, Xy}; -pub use screen_graphic::*; -pub use sequence_update_action::*; -use std::collections::HashSet; - -#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] -pub struct ProjectSharedData { - id: Uuid, - pub characters: Vec, -} -impl ProjectSharedData { - pub fn new(id: Uuid) -> Self { - Self { - id, - characters: vec![], - } - } - #[allow(dead_code)] - pub fn id(&self) -> Uuid { - self.id - } -} - -#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] -pub struct Character { - id: Uuid, - pub name: String, -} - -#[allow(dead_code)] -impl Character { - pub fn new(id: Uuid) -> Self { - Self { - id, - name: String::new(), - } - } - pub fn id(&self) -> Uuid { - self.id - } -} - -#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize, PartialEq)] -pub struct Sequence { - pub id: Uuid, - pub name: String, - pub cuts: Vec, -} -impl Sequence { - pub fn new(id: Uuid, name: String) -> Self { - Self { - id, - name, - cuts: vec![], - } - } -} - -#[derive( - Debug, Clone, Default, serde::Serialize, serde::Deserialize, PartialEq, PartialOrd, Eq, Ord, -)] -pub struct Label { - pub key: String, - pub value: String, -} - -#[derive( - Debug, Clone, Default, serde::Serialize, serde::Deserialize, PartialEq, PartialOrd, Eq, Ord, -)] -pub struct ImageWithLabels { - pub id: Uuid, - pub url: String, - pub labels: Vec